[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.0.RELEASE:repackage (default) on project device-factory-service: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.0.RELEASE:repackage failed: Duplicate library so.dian.dev-device-factory.jar -> [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]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :device-factory-service
在執行 mvn clean package 命令打包的時候,拋出上面異常,從錯誤信息上看,是說device-factory.jar 重復了,我找了半天也不知道這個包怎么重復了,在網上有看見說是插件沖突,我繼承了
spring-boot-starter-parent 包和spring-boot-maven-plugin 插件,因為parent中已經有了spring-boot-maven-plugin 插件,所以報錯,我按着這個將spring-boot-maven-plugin 刪掉確實可以打包了,但是各個工程之間依賴關系並沒有打下來。
最后跟一位大佬一起看才知道,我在父工程的pom.xml 定義了
<build>
<finalName>device-factory</finalName>
</build>
因為所有的子工程都繼承父的pom,所以其他自工程打出的包也叫device-factory.jar 所以才報重復。后將父工程中finalName刪除,果然包打好了,解壓后各工程的依賴也在。 我將finalName定義在我web工程pom中,也就是我的入口工程,發布的時候只需要將device-factory.jar 就可以了