使用 Maven 构建多模块项目
- 进入helloweb项目根目录,删除target目录
- 新建4个文件夹 helloweb-core && helloweb-entity && helloweb-parent && helloweb-web
- 将pom.xml 和 src 复制,分别放到4个目录中 && 删除src,修改pom.xml && 新建modules目录,将4个文件夹都放进去
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.coder352</groupId>
<artifactId>helloweb</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>helloweb</name>
<modules>
<module>modules/helloweb-parent</module>
<module>modules/helloweb-entity</module>
<module>modules/helloweb-core</module>
<module>modules/helloweb-web</module>
</modules>
</project>
- 导入Eclipse
- 修改helloweb-parent的pom.xml 文件,将packing改为pom,core和entity改为jar,web不用改
- 修改core,web,entity的pom.xml && 在groupId标签上面添加parent
<parent>
<groupId>com.coder352</groupId>
<artifactId>helloweb-parent</artifactId>
<version>1.0</version>
<relativePath></relativePath>
</parent>
- 修改四个pom.xml的artifactId,改为对应的-web -entity -parent -core
- 删除项目,重新导入