开发过程中遇到的一个问题。这个问题基本上是依赖包的问题。
下面是其中一种情况,发生在子模块与其他模块之间依赖的关系。
在a子模块中引用B模块生成的自定义依赖包,在idea编译器中也能通过快捷方式从a跳转B对应的类方法。但是运行a项目时,却一直报错,提示找不到B模块下对应的类方法。翻遍了网上的各种方法,一一尝试都没能生效。
install a模块的maven工程。查看报错数据,看到spring-boot-maven-plugin:2.3.12.RELEASE版本依赖有问题,版本低不支持。
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.12.RELEASE:
repackage (default) on project evcharge-thirdapi-otheroperators:
Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.3.12.RELEASE:
repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:2.3.12.RELEASE' due to an API incompatibility:
org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo : Unsupported major.minor version 52.0
接着去a项目的pom.xml文件里找这个依赖,发现这个依赖并没有加上版本号。为什么会有版本号出现并且报错。想到还有个A父模块,之前一直没关注他,是因为所有的修改没有动过他。然后打开A父模块的pom.xml文件,果不出其然,spring-boot-maven-plugin依赖在maven自动构建的时候偷偷加上了版本号。
去掉版本号,A父模块的maven点击clean再install,再到a子模块的maven中clean清除一下。重新运行a子模块的启动类。成功启动了。