JavaWeb——Maven聚合项目

一、创建MavenWeb项目

二、使用Maven整合SSM框架

1、使用创建好的Maven Web项目

在src/main/webapp下创建WEB-INF 以及 web.xml文件

2、配置pom文件,在pom中加入依赖

<!-- jar包配置 -->
 <dependencies>
  <!-- spring相关的jar -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-tx</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aspects</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jdbc</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jms</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context-support</artifactId>
   <version>${version.spring}</version>
  </dependency>
  <!-- mybaits以及整合spring -->
  <dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis</artifactId>
   <version>${version.mybatis}</version>
  </dependency>
  <dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis-spring</artifactId>
   <version>${version.mybatis-spring}</version>
  </dependency>
  <!-- 连接池jar -->
  <dependency>
   <groupId>commons-dbcp</groupId>
   <artifactId>commons-dbcp</artifactId>
   <version>1.4</version>
  </dependency>
  <dependency>
   <groupId>com.mchange</groupId>
   <artifactId>c3p0</artifactId>
   <version>0.9.5.2</version>
  </dependency>
  <dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>druid</artifactId>
   <version>1.1.10</version>
  </dependency>
  <!-- mysql驱动 -->
  <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>5.1.47</version>
  </dependency>
  <!-- pagephelper分页 -->
  <dependency>
   <groupId>com.github.pagehelper</groupId>
   <artifactId>pagehelper</artifactId>
   <version>5.1.2</version>
  </dependency>

  <!-- servlet相关的jar -->
  <dependency>
   <groupId>jstl</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <version>3.0.1</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jsp-api</artifactId>
   <version>2.0</version>
   <scope>provided</scope>
  </dependency>

  <!-- 文件上传 -->
  <dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.3.1</version>
  </dependency>
  <!-- springmvc 转化json -->
  <dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-databind</artifactId>
   <version>2.9.8</version>
  </dependency>
  <dependency>
   <groupId>taglibs</groupId>
   <artifactId>standard</artifactId>
   <version>1.1.2</version>
  </dependency>


  <!-- 日志jar -->
  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
   <version>1.7.25</version>
  </dependency>

 </dependencies>

3、将项目添加到tomcat

4、在pom中配置tomcat

5、使用Maven build

三、Maven聚合项目

在实际开发中会将项目分开

jar包版本管理、公共资源管理
项目管理器

  • 创建jar包版本管理类、并且Maven Install
  • 创建公共资源项目、并且Maven Install
  1. 创建项目管理Maven Project,继承jar包管理类
  2. 创建Maven Module,dao层选择父项目为项目管理器
  3. 创建Maven Module,sericice层选择父项目为dao层
  4. 创建Maven Module,web层选择父项目为sericice层

运行项目时只需要将项目管理的Maven Project运行即可

jingsongchan

发表评论

电子邮件地址不会被公开。 必填项已用*标注