Failed to execute goal: ...Compilation failure: Compilation failure:
Failed to execute goal: …Compilation failure: Compilation failure:
错误描述
基于SpringBoot2.0使用Maven构建了一个多模块项目,其中将项目中的公用模块抽离出来独立成工程,并在其它模块中引用该公用模块。但是,在使用maven install时,却总是抛出无法找到公用模块的类这样的错误。问题如下:
BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.446 s
[INFO] Finished at: 2018-09-15T17:47:06+08:00
[INFO] Final Memory: 40M/293M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo-tyrity: Compilation failure: Compilation failure:
[ERROR] /Users/tyrone/workspace/tyrone-demo/demo-tyrity/src/main/java/com/tyrone/o2o/tangpiao/service/impl/TangPiaoServiceImpl.java:[9,40] 程序包com.tyrone.o2o.service.tangpiao不存在
[ERROR] /Users/tyrone/workspace/tyrone-demo/demo-tyrity/src/main/java/com/tyrone/o2o/tangpiao/service/impl/TangPiaoServiceImpl.java:[14,45] 找不到符号
[ERROR] 符号: 类 ITangPiaoService
[ERROR] /Users/tyrone/workspace/tyrone-demo/demo-tyrity/src/main/java/com/tyrone/o2o/Application.java:[11,40] 程序包com.tyrone.o2o.service.tangpiao不存在
[ERROR] /Users/tyrone/workspace/tyrone-demo/demo-tyrity/src/main/java/com/tyrone/o2o/Application.java:[17,28] 找不到符号
[ERROR] 符号: 类 ITangPiaoService
[ERROR] 位置: 类 com.tyrone.o2o.Application
[ERROR] /Users/workspace/tyrone-demo/demo-tyrity/src/main/java/com/tyrone/o2o/tangpiao/service/impl/TangPiaoServiceImpl.java:[18,9] 方法不会覆盖或实现超类型的方法
[ERROR] /Users/tyrone/workspace/tyrone-demo/demo-tyrity/src/main/java/com/tyrone/o2o/tangpiao/service/impl/TangPiaoServiceImpl.java:[23,9] 方法不会覆盖或实现超类型的方法
[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]
解决方案
在spring-boot-maven-plugin
插件中增加如下属性:
<configuration>
<classifier>exec</classifier>
</configuration>
完整配置如下:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<configuration>
<classifier>exec</classifier>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
还没有评论,来说两句吧...