问题发现:

最近 发现在构建镜像时,始终编译报错,提示如下:

|- 2018-08-07 10:30:55,479 144140 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project prod-order-service: Compilation failure: Compilation failure:
|- 2018-08-07 10:30:55,480 144141 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] /home/ZCIPClient/workpath/7859/code/code/prod-order-service/src/main/java/com/ztesoft/bss/prod/order/ic/bll/SimCardValidationManager.java:[31,68] error: cannot find symbol
|- 2018-08-07 10:30:55,481 144142 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] symbol: class SingleNumberQueryReq
|- 2018-08-07 10:30:55,481 144142 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] location: package com.ztesoft.zsmart.bss.crm.ic.dubbo.logical.model.numberquery
|- 2018-08-07 10:30:55,482 144143 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] /home/ZCIPClient/workpath/7859/code/code/prod-order-service/src/main/java/com/ztesoft/bss/prod/order/ic/bll/SimCardValidationManager.java:[32,68] error: cannot find symbol
|- 2018-08-07 10:30:55,482 144143 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] symbol: class SingleNumberQueryResp
|- 2018-08-07 10:30:55,483 144144 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] location: package com.ztesoft.zsmart.bss.crm.ic.dubbo.logical.model.numberquery
|- 2018-08-07 10:30:55,483 144144 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] /home/ZCIPClient/workpath/7859/code/code/prod-order-service/src/main/java/com/ztesoft/bss/prod/order/ic/bll/SimCardValidationManager.java:[34,69] error: cannot find symbol
|- 2018-08-07 10:30:55,492 144153 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] symbol: class SingleSimCardQueryReq
|- 2018-08-07 10:30:55,493 144154 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] location: package com.ztesoft.zsmart.bss.crm.ic.dubbo.logical.model.simcardquery
|- 2018-08-07 10:30:55,493 144154 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] /home/ZCIPClient/workpath/7859/code/code/prod-order-service/src/main/java/com/ztesoft/bss/prod/order/ic/bll/SimCardValidationManager.java:[35,69] error: cannot find symbol
|- 2018-08-07 10:30:55,493 144154 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - [ERROR] -> [Help 1]
|- 2018-08-07 10:30:55,494 144155 INFO [main ] (com.ci.helper.MavenCompileHelper.java:670) - org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project prod-order-service: Compilation failure

提示找不到class SingleSimCardQueryReq;

解决思路:

先在本地根据提示编译了一次,没有问题,然后找到这个这个class所在的jar及路径,在容器中找到仓库里对应的目录下存在这个jar,打开后发现这个jar里确实没有这个class;然后看了下这个jar的maven-metadata:

发现这里的时间是晚于仓库上这个jar的最新时间的,所以不会取仓库中的jar。仓库中的jar上传的有问题。

总结:

maven取jar包时的机制是根据时间对比,去最新的jar,若maven-metadata中的时间比仓库中的jar的时间早,则会取最新的jar,若比jar的最新时间还要晚,肯定就不会取了。 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐