1.问题
子模块scnu-core中不能调用其他模块scnu-common的类。
本项目父模块为srb,scnu-common、scnu-base、scnu-core均为srb的子模块,且scnu-base引用scnu-common依赖、scnu-core引用scnu-base依赖。
2.解决方法
先查看父pom文件有没有定义子模块
父模块为:
<groupId>com.scnu</groupId>
<artifactId>srb</artifactId>
<version>0.0.1-SNAPSHOT</version>
其子模块定义
<modules>
<module>scnu-common</module>
<module>service-base</module>
<module>service-core</module>
</modules>
scnu-common、scnu-base、scnu-core每个模块都要有父模块的说明:
<parent>
<artifactId>srb</artifactId>
<groupId>com.scnu</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
再查看子模块有没有引入对应的依赖
scnu-base:
<dependency>
<groupId>com.scnu</groupId>
<artifactId>scnu-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
scnu-core:
<dependency>
<groupId>com.scnu</groupId>
<artifactId>service-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
这时,如果scnu-core仍然不能引入scnu-common的类,则右键子模块scnu-core,选择Maven,选择Reimport解决问题。
ps:本文方法不具备通用性