idea spring boot docker 多項目 maven 編譯

1,重複的modeljava

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'modules.module[6]' specifies duplicate child module authService @ line 15, column 17
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project cn.meylink:root:1.0-SNAPSHOT (E:\Documents\Projects\cn.meylink\pom.xml) has 1 error
[ERROR]     'modules.module[6]' specifies duplicate child module authService @ line 15, column 17
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

在主pom.xml文件的models節點 移除 指定位置 重複的 model 我這裏提示的 pom.xml 15行 authService重複web

2,maven-plugin-plugin版本太低,升級spring

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor (default-descriptor) on project pojo: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor failed: 10024 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pojo

找到pom文件(但是是根pom也但是當前model的pom,我這裏提到的事pojo這個model,爲了一勞永逸我在root pom上統一處理),build->plugins->plugin加入紅色部分docker

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-plugin-plugin</artifactId>
    <version>3.5</version>
</plugin>

3,No mojo definitions were found for pluginapache

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor (default-descriptor) on project pojo: Error extracting plugin descriptor: 'No mojo definitions were found for plugin: cn.meylink.mall:pojo.' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pojo

這個問題百度好久解決不了,只能先跳過,找到pom文件加入紅色部分,build->plugins->plugin加入紅色部分app

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-plugin-plugin</artifactId>
    <version>3.5</version>
    <configuration>
      <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
      <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
  </configuration>
</plugin>

5,model編譯類型錯誤socket

[ERROR] Failed to execute goal on project commonWeb: Could not resolve dependencies for project commonWeb:maven-plugin:1.0-SNAPSHOT: Could not find artifact commonBase:jar:1.0-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :commonWeb

繼續往上查看輸入日誌:maven

[INFO] Building commonBase 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ commonBase ---
[INFO] Installing E:\Documents\Projects\cn.meylink\commonBase\pom.xml to C:\Users\Administrator\.m2\repository\cn\meylink\commonBase\1.0-SNAPSHOT\commonBase-1.0-SNAPSHOT.pom
[INFO]                                                                         
被編譯爲:commonBase-1.0-SNAPSHOT.pom,而引用中須要 commonBase-1.0-SNAPSHOT.jar,修改被引用model生成類型爲 jar 即:
 <packaging>maven-plugin</packaging>

6,註釋錯誤spring-boot

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor (default-descriptor) on project repository: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor failed: syntax error @[11,126] in file:/E:/Documents/Projects/cn.meylink/mall/repository/src/main/java/cn/meylink/mall/repository/CategoryInfoRepository.java -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :repository

很奇怪,去看看  [11,126] in file:/E:/Documents/Projects/cn.meylink/mall/repository/src/main/java/cn/meylink/mall/repository/CategoryInfoRepository.java  文件內容以下:ui

7,所有 install 完成

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] root .................................... SUCCESS [ 0.296 s]
[INFO] mall .................................... SUCCESS [ 0.021 s]
[INFO] mall.pojo ............................... SUCCESS [ 5.967 s]
[INFO] mall.mapper ............................. SUCCESS [ 2.480 s]
[INFO] commonBase .............................. SUCCESS [ 0.023 s]
[INFO] commonWeb Maven Mojo ............................... SUCCESS [ 2.453 s]
[INFO] mall.service ............................ SUCCESS [ 3.515 s]
[INFO] mall .................................... SUCCESS [ 19.318 s]
[INFO] mall.model .............................. SUCCESS [ 1.727 s]
[INFO] mall.webManage .......................... SUCCESS [ 9.473 s]
[INFO] mall.webAdmin ........................... SUCCESS [ 9.042 s]
[INFO] authService ............................. SUCCESS [ 2.897 s]
[INFO] webSocket ............................... SUCCESS [ 11.171 s]
[INFO] yuec2c .................................. SUCCESS [ 0.020 s]
[INFO] pojo Maven Mojo .................................... SUCCESS [ 2.042 s]
[INFO] yuec2c.repository ....................... SUCCESS [ 1.971 s]
[INFO] yuec2c.service .......................... SUCCESS [ 2.743 s]
[INFO] yuec2c.webApi ........................... SUCCESS [ 17.222 s]
[INFO] fileService ........................................ SUCCESS [ 12.551 s]
[INFO] worker ............................................. SUCCESS [ 3.406 s]
[INFO] commonQueue Maven Mojo ............................. SUCCESS [ 1.094 s]
[INFO] payment ............................................ SUCCESS [ 11.515 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:02 min
[INFO] Finished at: 2019-02-18T19:17:36+08:00
[INFO] Final Memory: 132M/1514M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

 8,docker build :pom.xml添加一個build->plugins->plugin內容以下:

<!-- Docker maven plugin -->
<plugin>
    <!-- https://mvnrepository.com/artifact/com.spotify/docker-maven-plugin -->
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>1.2.0</version>
    <configuration>
       <imageName>${docker.image.prefix}/${project.name}</imageName>
        <dockerDirectory>src/main/docker</dockerDirectory>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.war</include>
            </resource>
        </resources>
    </configuration>
</plugin>
<!-- Docker maven plugin -->

執行 maven 命令

package docker:build

(1)Dockerfile文件不存在或路徑錯誤

[INFO] --- docker-maven-plugin:1.2.0:build (default-cli) @ authService ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] No Dockerfile in dockerDirectory
[INFO] Skipping docker build
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.569 s
[INFO] Finished at: 2019-02-19T09:47:40+08:00
[INFO] Final Memory: 55M/556M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

上面沒有啓動docker編輯 顯示沒找到Dockerfile文件,檢查你的Dockerfile文件路徑與文件名是否正確

 

(2)image名稱不能包含大寫字母

[INFO] Building image ejiyuan/authService
二月 19, 2019 9:38:29 上午 com.spotify.docker.client.shaded.org.apache.http.impl.execchain.RetryExec execute
信息: I/O exception (java.net.SocketException) caught when processing request to {s}->https://192.168.99.100:2376: Connection reset by peer: socket write error
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.700 s
[INFO] Finished at: 2019-02-19T09:38:29+08:00
[INFO] Final Memory: 66M/553M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.0:build (default-cli) on project authService: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: com.spotify.docker.client.shaded.org.apache.http.client.ClientProtocolException: Cannot retry request with a non-repeatable request entity: Connection reset by peer: socket write error -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我這裏image name 等於 「<imageName>${docker.image.prefix}/${project.name}</imageName>」 是兩個變量,查看project.name,爲「authService" 包含了大寫字母,修改成小寫便可 

 9,運行時錯誤

no main manifest attribute, in /xxxx.war

項目model中pom.xml文件的 build->plugins->plugin節點加入「spring-boot-maven-plugin」

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

注意 不要加載root的 pom.xml中,只能在,啓動的 war項目中,否者 沒有標記「@SpringBootApplication」的非啓動model會報錯「repackage failed: Unable to find main class -> [Help 1]」

相關文章
相關標籤/搜索