【报错】
- 使用nacos导入配置文件报错:未读取到合法数据,请检查导入的数据文件。
【原因】
- 对比在naocs server中导出的文件,发现是少了一级目录。需要创建一个文件夹,名称为组的名称。
- 因为在nacos上传文件时是可以选择命名空间的,但是不会选择组,所以nacos server识别报错了。
【解决】
- 创建文件夹,命名为DEFAULT_GROUP,然后将配置文件放进去,打包上传成功。
- 将修改的配置文件压缩成zip文件——上传配置文件。
【报错】
ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (build-image) on project
【解决】
- 创建habor仓库,配置http模式。
- docker加入harbor仓库认证.。
- 服务器登录harbor仓库成功。
- 修改pom.xml中仓库地址为:http://192.168.4.119:2375。
- 执行行mvn clean package docker:build。
- 确认生成镜像并且已经上传到仓库。
【报错】
Failed to execute goal on project mall-common: Could not resolve dependencies for project com.macro.mall:mall-common:jar:1.0-SNAPSHOT: Failed to collect dependencies for [com.github.pagehelper:pagehelper:jar:5.2.0 (compile), org.springframework.boot:spring-boot-starter-web:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-data-redis:jar:2.3.0.RELEASE (compile), org.springframework.data:spring-data-commons:jar:2.3.0.RELEASE (compile), com.github.xiaoymin:knife4j-micro-spring-boot-starter:jar:2.0.4 (compile), net.logstash.logback:logstash-logback-encoder:jar:5.3 (compile), org.springframework.boot:spring-boot-starter-validation:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-actuator:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-aop:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-test:jar:2.3.0.RELEASE (test), cn.hutool:hutool-all:jar:5.4.0 (compile), org.projectlombok:lombok:jar:1.18.12 (compile), org.springframework.boot:spring-boot-configuration-processor:jar:2.3.0.RELEASE (compile?)]: Failed to read artifact descriptor for org.apiguardian:apiguardian-api:jar:1.1.0: Could not transfer artifact org.apiguardian:apiguardian-api:pom:1.1.0 from/to aliyunmaven (https://maven.aliyun.com/repository/public): maven.aliyun.com: 未知的名称或服务: Unknown host maven.aliyun.com: 未知的名称或服务
【解决】
[root@localhost ~]# vim /opt/mall-swarm-master/pom.xml
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
【报错】
Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (default-cli) on project mall-common: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: com.spotify.docker.client.shaded.org.apache.http.conn.HttpHostConnectException: Connect to 192.168.4.114:2376 [/192.168.4.114] failed: 拒绝连接 (Connection refused) -> [Help 1]
【解决】查看2376端口
\cp /usr/lib/systemd/system/docker.service /usr/lib/systemd/system/docker.service.`date +%Y-%m-%d-%T`
sed -i "s/ExecStart/#ExecStart/g" /usr/lib/systemd/system/docker.service
sed -i '11i ExecStart=/usr/bin/dockerd \\' /usr/lib/systemd/system/docker.service
sed -i '12i --tlsverify \\' /usr/lib/systemd/system/docker.service
sed -i '13i --tlscacert=/etc/docker/ca.pem \\' /usr/lib/systemd/system/docker.service
sed -i '14i --tlscert=/etc/docker/server-cert.pem \\' /usr/lib/systemd/system/docker.service
sed -i '15i --tlskey=/etc/docker/server-key.pem \\' /usr/lib/systemd/system/docker.service
sed -i '16i -H tcp://0.0.0.0:2376 \\' /usr/lib/systemd/system/docker.service
sed -i '17i -H unix:///var/run/docker.sock \' /usr/lib/systemd/system/docker.service
echo -e '\033[41;36m docker配置文件修改成功\033[0m'
#查看
cat /usr/lib/systemd/system/docker.service
#加入仓库地址
cat >/etc/docker/daemon.json<<EOF
{"insecure-registries":["https://$SERVER"]}
EOF
# 重新加载文件
systemctl daemon-reload
systemctl restart docker.service
systemctl status docker.service
echo -e '\033[41;36m docker重启完毕033[0m'
#直接使用docker-maven-plugin打包试试,由于我们的插件版本有点低,使用新一点版本的Docker会出现如下问题,升级到1.2.2版本解决该问题;
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.1.0:build (build-image) on project mall-tiny-docker: Exception caught: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.spotify.docker.client.messages.RegistryAuth` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('desktop')
[ERROR] at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: java.util.LinkedHashMap["credsStore"])
[ERROR] -> [Help 1]
#修改完版本后打包,发现TLS不再支持http了,需要改用https,修改<dockerHost>配置为https;
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (build-image) on project mall-tiny-docker: Exception caught: Request error: GET http://192.168.3.101:2375/version: 400, body: Client sent an HTTP request to an HTTPS server. HTTP 400 Bad Request -> [Help 1]
#修改完成后再次打包,继续失败,需要添加对应的客户端证书才能访问;
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (build-image) on project mall-tiny-docker: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
#将如下文件复制到指定目录,这里复制到了I:\developer\env\docker-ca;
ca.pem CA证书
cert.pem 客户端证书
key.pem 客户端证书私钥