【DOCKER】部署SPRINGBOOG项目错误集

2021-11-04  本文已影响0人  地主家有30头牛

【错误1】
现象:
使用[mvn package]命令打包,报错[No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?]

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.884 s
[INFO] Finished at: 2021-11-05T16:26:31+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project docker-test: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[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/MojoFailureException

解决方案:
SPRINGBOOT的POM配置里指定JDK绝对路径

<plugin>
        <!-- 指定maven编译的jdk版本 -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                    <verbose>true</verbose>
                    <fork>true</fork>
                    <!--你的jdk地址-->
                    <executable>C:\Program Files (x86)\Java\jdk1.8.0_261\bin/javac</executable>
              </configuration>
</plugin>

【错误2】
现象:
执行命令[mvn package docker:build],报错[com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.spotify.docker.client.messages.RegistryAuth: no String-argument constructor/factory method to deserialize from String value ('desktop')]

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.092 s
[INFO] Finished at: 2021-11-05T16:17:30+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project docker-test: Exception caught: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.spotify.docker.client.messages.RegistryAuth: no String-argument constructor/factory method to deserialize from String value ('desktop')
[ERROR]  at [Source: N/A; line: -1, column: -1] (through reference chain: java.util.LinkedHashMap["credsStore"])
[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

解决方案:
去掉POM里,docker-maven-plugin 的版本信息。
原本配置了
<version>1.0.0</version>

<plugin>
              <groupId>com.spotify</groupId>
              <artifactId>docker-maven-plugin</artifactId>
              <configuration>
              <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
              <dockerDirectory>src/main/docker</dockerDirectory>
              <resources>
               <resource>
               <targetPath>/</targetPath>
               <directory>${project.build.directory}</directory>
               <include>${project.build.finalName}.jar</include>
               </resource>
              </resources>
              </configuration>
             </plugin>

【错误3】
现象:

Step 1/4 : FROM openjdk:8-jdk-alpine

Pulling from library/openjdk
Pulling from library/openjdk
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:27 min
[INFO] Finished at: 2021-11-05T14:59:03+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default-cli) on project docker-test: Exception caught: no matching manifest for windows/amd64 10.0.19043 in the manifest list entries -> [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

解决方案:
DOCKER托盘图标右键菜单选择[settings],在[Docker Engine]里设置 "experimental": true


docker.jpg
上一篇下一篇

猜你喜欢

热点阅读