1.如果是父模块下有多个子模块,common模块在子模块中,pom文件中应有如下内容:
common模块的pom.xml
<parent>
<artifactId>praent</artifactId>
<groupId>域名</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>域名</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
praent模块的pom.xml
<modules>
<module>common</module>
</modules>
在使用common模块前要运行package:
并且使用common模块前 需要导入common模块的包:
2.如果common模块和需要使用common模块的模块不在同一个父模块中:
common模块的pom.xml:
<groupId>com.itheima</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
使用前也必须运行package
需要使用common模块的模块的pom.xml:
<dependency>
<groupId>域名</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
大功告成,被这模块之间的关系折磨的死去活来 [偷笑] [偷笑] [偷笑]