Maven多模块项目搭建+SSM框架整合(一、多模块搭建)
</div>
</div>
</div>
</div>
<!-- 手记详情 -->
<div class="detail-content-wrap">
<div class="detail-content js-lookimg">
<div><p>项目使用IDEA进行构建,源码将会提交到GitHub上,使用Eclipse的用户也可以轻松导入。</p>
在此我们将项目划分为4块,分别为model、dao、service和controller。
一、创建父模块
打开IDEA创建项目
<!–添加start–>
<packaging>jar</packaging>
<!–添加end–>
</project>
配置mytest-dao中的pom.xml
<?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"> <parent> <artifactId>mytest-root</artifactId> <groupId>com.songci</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion>
<artifactId>mytest-dao</artifactId>
<!–添加start–>
<packaging>jar</packaging>
<!–添加对mytest-model的依赖–>
<dependencies>
<dependency>
<groupId>com.songci</groupId>
<artifactId>mytest-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<!–添加end–>
</project>
配置mytest-service中的pom.xml
<?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"> <parent> <artifactId>mytest-root</artifactId> <groupId>com.songci</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion>
<artifactId>mytest-service</artifactId>
<!–添加start–>
<packaging>jar</packaging>
<dependencies>
<!--添加对mytest-model的依赖-->
<dependency>
<groupId>com.songci</groupId>
<artifactId>mytest-model</artifactId>
<version>${project.version}</version>
</dependency>
<!--添加对mytest-dao的依赖-->
<dependency>
<groupId>com.songci</groupId>
<artifactId>mytest-dao</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<!–添加end–>
</project>
配置mytest-web中的pom.xml
<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/maven-v4_0_0.xsd">
<parent>
<artifactId>mytest-root</artifactId>
<groupId>com.songci</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mytest-web</artifactId>
<packaging>war</packaging>
<name>mytest-web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--添加start-->
<!--添加对mytest-model的依赖-->
<dependency>
<groupId>com.songci</groupId>
<artifactId>mytest-model</artifactId>
<version>${project.version}</version>
</dependency>
<!--添加对mytest-dao的依赖-->
<dependency>
<groupId>com.songci</groupId>
<artifactId>mytest-dao</artifactId>
<version>${project.version}</version>
</dependency>
<!--添加对mytest-service的依赖-->
<dependency>
<groupId>com.songci</groupId>
<artifactId>mytest-service</artifactId>
<version>${project.version}</version>
</dependency>
<!--添加end-->
</dependencies>
<build>
<finalName>mytest-web</finalName>
</build>
</project>
配置mytest_one中的pom.xml(就是最外面那个pom.xml)
<?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.songci</groupId> <artifactId>mytest-root</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>mytest-model</module> <module>mytest-dao</module> <module>mytest-service</module> <module>mytest-web</module> </modules>
<!–添加start–>
<!–项目统一字符集编码–>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!–添加end–>
</project>
以上maven多模块就搭建好了,接下来我们在该项目基础上对Spring、SpringMVC、Mybatis进行整合
下一篇
Maven-maven多模块项目搭建+SSM框架整合((二、Dao层添加测试,服务层添加))
GitHub地址:https://github.com/iamsongci/mytest_one
未完待续--------
</div>