[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project ly-item-interface: Compilation failure: Compilation failure:
[ERROR] /D:/javacode/idea/leyou/ly-item/ly-item-interface/src/main/java/com/leyou/item/api/GoodsApi.java:[3,28] 程序包com.leyou.common.dto不存在
[ERROR] /D:/javacode/idea/leyou/ly-item/ly-item-interface/src/main/java/com/leyou/item/api/GoodsApi.java:[4,27] 程序包com.leyou.common.vo不存在
[ERROR] /D:/javacode/idea/leyou/ly-item/ly-item-interface/src/main/java/com/leyou/item/api/GoodsApi.java:[23,5] 找不到符号
[ERROR] 符号: 类 PageResult
[ERROR] 位置: 接口 com.leyou.item.api.GoodsApi
[ERROR] /D:/javacode/idea/leyou/ly-item/ly-item-interface/src/main/java/com/leyou/item/api/GoodsApi.java:[37,42] 找不到符号
[ERROR] 符号: 类 CartDTO
[ERROR] 位置: 接口 com.leyou.item.api.GoodsApi
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :ly-item-interface
Process finished with exit code 1
ly-item-interface: Compilation failure: Compilation failure:
[ERROR] com/leyou/item/api/GoodsApi. 程序包com.leyou.common.dto不存在
ly-item-interface在打包时要依赖com.leyou.common包
就很奇怪 明明这个包这个类都是存在的啊,为什么就是找不到???
其次做了几项检查:
最终原因,其实就是没有依赖。。。原因就是spring-boot-maven-plugin
这个坑!!!用这个插件打包的Jar包可以直接运行,但是不可依赖!!!所以interface自始至终就没有依赖,自然会说找程序包不存在或者找不到类
最后修改pom.xml的依赖:
org.springframework.boot
spring-boot-maven-plugin
execute
ok!
一个微服务通常有两个子module,一般一个写实体类和接口一个写实现方法
建议
org.springframework.boot
spring-boot-maven-plugin
none
execute
注:
none
是为了解决Unable to find main class
的问题,当然,如果写了简单的main函数这几行可以不写~
org.springframework.boot
spring-boot-maven-plugin
一晚上将近三个小时,碰到打包时的各种奇葩问题(为什么老师一按install好好的,我就???),还好最后看到了BUILD SUCCESS
,等待他打包的过程好紧张,就怕有错,哭辽~