Maven.zzh

什么是Maven

Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。
Maven 除了以程序构建能力为特色之外,还提供高级项目管理工具。由于 Maven 的缺省构建规则有较高的可重用性,所以常常用两三行 Maven 构建脚本就可以构建简单的项目。由于 Maven 的面向项目的方法,许多 Apache Jakarta 项目发文时使用Maven

Maven的好处

1、依赖管理: maven项目没有jar包,其需要的jar包存放在本地仓库中,原理如下:
1480266-20180906213152440-1770863961.jpg
2、一键构建:编译,测试,运行,打包,部署   在命令行中相应的盘符下输入tomcat:run就能把一个已有的maven项目运行起来
3、可以跨平台:应用于大型项目,可以提高开发效率
4、分模块开发

Maven的安装

Maven需要配置java环境变量
Maven3.3.X所需要的jdk都是需要1.7以上的版本

在config文件夹中的settings.xml中配置相应参数
配置本地仓库:
	<localRepository>D:\repository</localRepository>
1
 
1
    <localRepository>D:\repository</localRepository>
1480266-20180906213152802-1609444657.png

Maven有本地仓库(自己维护),远程仓库(公司维护)和中央仓库(maven团队维护)三种,关系如下图:
1480266-20180906213153156-1851190797.png


Maven环境变量配置

1、在系统变量添加:
环境变量的名称:MAVEN_HOME
变量值: maven软件解压的目录→D:\apache-maven-3.3.9
1480266-20180906213153471-519414879.png

2、把MAVEN_HOME添加到path里:
1480266-20180906213153773-1449980800.png

3、验证maven是否配置成功:
打开dos窗口,输入 mvn -v,出现以下语句则为配置成功
1480266-20180906213154086-1320414486.png




Maven的目录结构:

1480266-20180906213154457-466556120.jpg

Maven的常用命令:

clean:清理target文件夹
compile:编译(仅编译主目录下的java文件)
test:编译并运行了test目录下的文件
package
install:把项目发布到本地仓库
tomcat:run,一键运行


Maven的三种生命周期:

(1)clean生命周期
(2)Default生命周期 Compile test package install deploy(发布到私服)
(3)Site生命周期 site(生成项目的站点文档)

Eclipse配置插件

1、选择安装好的maven软件
1480266-20180906213154824-507875628.png

2、修改默认的本地仓库地址
1480266-20180906213155344-164629841.png



Maven项目的创建

1.新建一个maven项目
2.跳过骨架,否则创建出来的项目结构不完整,缺少resource文件夹
1480266-20180906213155737-2010207133.png

3.填写坐标
1480266-20180906213156082-422600507.png

4.在src/main/webapp下新建一个WEB-INF文件夹,在里面放置一个web.xml文件
5.在pom.xml中添加下面这段代码配置编译版本
  <build>
    <!-- 添加插件 -->
  	<plugins>
  		<plugin>
  			<groupId>org.apache.maven.plugins</groupId>
  			<artifactId>maven-compiler-plugin</artifactId>
  			<configuration>
  				<source>1.8</source>
  				<target>1.8</target>
  				<encoding>UTF-8</encoding>
  			</configuration>
  		</plugin>
  	</plugins>
  </build>
14
 
1
  <build>
2
    <!-- 添加插件 -->
3
    <plugins>
4
        <plugin>
5
            <groupId>org.apache.maven.plugins</groupId>
6
            <artifactId>maven-compiler-plugin</artifactId>
7
            <configuration>
8
                <source>1.8</source>
9
                <target>1.8</target>
10
                <encoding>UTF-8</encoding>
11
            </configuration>
12
        </plugin>
13
    </plugins>
14
  </build>
6.在pom.xml文件中添加下面这段代码配置引入本地仓库中的jar包
  	//添加依赖
    <dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.9</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.0</version>
			<scope>provided</scope>
		</dependency>
		
	</dependencies>
22
 
1
    //添加依赖
2
    <dependencies>
3
        <dependency>
4
            <groupId>junit</groupId>
5
            <artifactId>junit</artifactId>
6
            <version>4.9</version>
7
            <scope>test</scope>
8
        </dependency>
9
        <dependency>
10
            <groupId>javax.servlet</groupId>
11
            <artifactId>servlet-api</artifactId>
12
            <version>2.5</version>
13
            <scope>provided</scope>
14
        </dependency>
15
        <dependency>
16
            <groupId>javax.servlet</groupId>
17
            <artifactId>jsp-api</artifactId>
18
            <version>2.0</version>
19
            <scope>provided</scope>
20
        </dependency>
21
        
22
    </dependencies>

7、添加坐标 选择Dependencies 点击add,手动输入要添加的坐标,选择版本
1480266-20180906213156561-1431204781.png
此时pom.xml文件 出现
1480266-20180906213156892-94118851.png

8、同样的方式添加serlvet-api.jar和jsp-api.jar 注意选择scope为provided
9、书写action代码,修改web.xml文件
10、启动项目  右击项目 run as→maven build
1480266-20180906213157225-19087200.png

依赖范围

依赖范围是什么?

maven 项目不同的阶段引入到classpath中的依赖是不同的,例如,编译时,maven 会将与编译相关的依赖引入classpath中,测试时,maven会将测试相关的的依赖引入到classpath中,运行时,maven会将与运行相关的依赖引入classpath中,而依赖范围就是用来控制依赖于这三种classpath的关系

1、Compile(该范围就是默认依赖范围,此依赖范围对 于编译、测试、运行三种classpath都有效)   如struts2-core
  编译( compile )时需要 测试时需要,运行时需要,打包时需要

2、Provided(使用该依赖范围的maven依赖,只对编译和测试的classpath有效,对运行的classpath无效,在运行时,web容器已经提供的该依赖,所以运行时就不再需要此依赖,如果不显示指定该依赖范围,并且容器依赖的版本和maven依赖的版本不一致的话,可能会引起版本冲突,造成不良影响)  
 如jsp-api.jar servlet-api.jar
  编译( compile )时需要,测试( test )时也需要 ,运行时不需要,打包时不需要

3、Runtime(只对测试和运行的classpath有效,对编译的classpath无效,典型例子就是JDBC的驱动实现,项目主代码编译的时候只需要JDK提供的JDBC接口,只有在测试和运行的时候才需要实现上述接口的具体JDBC驱动)
 如数据库驱动包
 编译时不需要,测试时需要,运行时需要,打包时需要

4、Test(针对于测试,使用此依赖范围的依赖,只对测试classpath有效,在编译主代码和项目运行时,都将无法使用该依赖)
 如junit.jar

 编译时不需要,测试时需要,运行时不需要,打包也不需要

总结

<modelVersion>
坐标(GAV): <groupId></groupId>
            <artifactId></artifactId>
            <version></version>
Package(打包方式):jar,war,pom
依赖:<dependencies></dependencies>
插件在build标签中,<plugin></plugin>

版本冲突解决方法

1、第一声明优先原则
<dependencies>
  <!--   spring-beans-4.2.4 -->
  	<dependency>
  		<groupId>org.springframework</groupId>
  		<artifactId>spring-context</artifactId>
  		<version>4.2.4.RELEASE</version>
  	</dependency>
  
  
<!--   spring-beans-3.0.5 -->
  	<dependency>
  		<groupId>org.apache.struts</groupId>
  		<artifactId>struts2-spring-plugin</artifactId>
  		<version>2.3.24</version>
  	</dependency>
16
 
1
<dependencies>
2
  <!--   spring-beans-4.2.4 -->
3
    <dependency>
4
        <groupId>org.springframework</groupId>
5
        <artifactId>spring-context</artifactId>
6
        <version>4.2.4.RELEASE</version>
7
    </dependency>
8
  
9
  
10
<!--   spring-beans-3.0.5 -->
11
    <dependency>
12
        <groupId>org.apache.struts</groupId>
13
        <artifactId>struts2-spring-plugin</artifactId>
14
        <version>2.3.24</version>
15
    </dependency>
16
 
          
2、路径近者优先原则(自己添加jar包)
	<dependency>
  		<groupId>org.springframework</groupId>
  		<artifactId>spring-beans</artifactId>
  		<version>4.2.4.RELEASE</version>
  	</dependency>
6
 
1
    <dependency>
2
        <groupId>org.springframework</groupId>
3
        <artifactId>spring-beans</artifactId>
4
        <version>4.2.4.RELEASE</version>
5
    </dependency>
6
 
          
3、排除原则
  	<dependency>
  		<groupId>org.apache.struts</groupId>
  		<artifactId>struts2-spring-plugin</artifactId>
  		<version>2.3.24</version>
  		<exclusions>
  		  <exclusion>
  		    <groupId>org.springframework</groupId>
  		    <artifactId>spring-beans</artifactId>
  		  </exclusion>
  		</exclusions>
  	</dependency>
12
 
1
    <dependency>
2
        <groupId>org.apache.struts</groupId>
3
        <artifactId>struts2-spring-plugin</artifactId>
4
        <version>2.3.24</version>
5
        <exclusions>
6
          <exclusion>
7
            <groupId>org.springframework</groupId>
8
            <artifactId>spring-beans</artifactId>
9
          </exclusion>
10
        </exclusions>
11
    </dependency>
12
 
          
4、版本锁定原则
<properties>
		<spring.version>4.2.4.RELEASE</spring.version>
		<hibernate.version>5.0.7.Final</hibernate.version>
		<struts.version>2.3.24</struts.version>
	</properties>

	<!-- 锁定版本,struts2-2.3.24、spring4.2.4、hibernate5.0.7 -->
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${spring.version}</version>
			</dependency>
</dependencies>
</dependencyManagement>
17
 
1
<properties>
2
        <spring.version>4.2.4.RELEASE</spring.version>
3
        <hibernate.version>5.0.7.Final</hibernate.version>
4
        <struts.version>2.3.24</struts.version>
5
    </properties>
6
 
          
7
    <!-- 锁定版本,struts2-2.3.24、spring4.2.4、hibernate5.0.7 -->
8
    <dependencyManagement>
9
        <dependencies>
10
            <dependency>
11
                <groupId>org.springframework</groupId>
12
                <artifactId>spring-context</artifactId>
13
                <version>${spring.version}</version>
14
            </dependency>
15
</dependencies>
16
</dependencyManagement>
17
 
          

依赖传递和依赖范围的关系

1480266-20180906213157834-568694558.jpg



私服nexus

仓库类型:virtual——虚拟仓库,proxy——代理仓库,hosted——本地仓库,group仓库

eg.把dao发布到私服上
在dao中的pom.xml添加下列代码
<distributionManagement>
  	<repository>
  		<id>releases</id>
	<url>http://localhost:8081/nexus/content/repositories/releases/</url>
  	</repository> 
  	<snapshotRepository>
  		<id>snapshots</id>
	<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
  	</snapshotRepository> 
  </distributionManagement>
10
 
1
<distributionManagement>
2
    <repository>
3
        <id>releases</id>
4
    <url>http://localhost:8081/nexus/content/repositories/releases/</url>
5
    </repository> 
6
    <snapshotRepository>
7
        <id>snapshots</id>
8
    <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
9
    </snapshotRepository> 
10
  </distributionManagement>
在settings.xml文件中添加下列代码
<server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
	<server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
</server>
10
 
1
<server>
2
      <id>releases</id>
3
      <username>admin</username>
4
      <password>admin123</password>
5
    </server>
6
    <server>
7
      <id>snapshots</id>
8
      <username>admin</username>
9
      <password>admin123</password>
10
</server>
在settings.xml文件中配置从nexus上下载依赖的地址
    <profile>
    <id>dev</id>   
    <repositories>   
      <repository>  
		<!--仓库id,repositories可以配置多个仓库,保证id不重复-->
        <id>nexus</id>   
		<!--仓库地址,即nexus仓库组的地址-->
        <url>http://localhost:8081/nexus/content/groups/public/</url>   
		<!--是否下载releases构件-->
        <releases>   
          <enabled>true</enabled>   
        </releases>   
		<!--是否下载snapshots构件-->
        <snapshots>   
          <enabled>true</enabled>   
        </snapshots>   
      </repository>   
    </repositories>  
	 <pluginRepositories>  
    	<!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
        <pluginRepository>  
        	<!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
            <id>public</id>  
            <name>Public Repositories</name>  
            <url>http://localhost:8081/nexus/content/groups/public/</url>  
        </pluginRepository>  
    </pluginRepositories>  
	</profile> 
	  
      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
33
 
1
    <profile>
2
    <id>dev</id>   
3
    <repositories>   
4
      <repository>  
5
        <!--仓库id,repositories可以配置多个仓库,保证id不重复-->
6
        <id>nexus</id>   
7
        <!--仓库地址,即nexus仓库组的地址-->
8
        <url>http://localhost:8081/nexus/content/groups/public/</url>   
9
        <!--是否下载releases构件-->
10
        <releases>   
11
          <enabled>true</enabled>   
12
        </releases>   
13
        <!--是否下载snapshots构件-->
14
        <snapshots>   
15
          <enabled>true</enabled>   
16
        </snapshots>   
17
      </repository>   
18
    </repositories>  
19
     <pluginRepositories>  
20
        <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
21
        <pluginRepository>  
22
            <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
23
            <id>public</id>  
24
            <name>Public Repositories</name>  
25
            <url>http://localhost:8081/nexus/content/groups/public/</url>  
26
        </pluginRepository>  
27
    </pluginRepositories>  
28
    </profile> 
29
      
30
      <properties>
31
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
32
      </properties>
33
    </profile>
激活profile配置
  <activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>
3
 
1
  <activeProfiles>
2
    <activeProfile>dev</activeProfile>
3
  </activeProfiles>

Maven分模块开发

Maven多模块项目,适用于一些比较大的项目,通过合理的模块拆分,实现代码的复用,便于维护和管理。尤其是一些开源框架,也是采用多模块的方式,提供插件集成,用户可以根据需要配置指定的模块

分模块开发基于集成和聚合原理

继承:继承是为了消除重复,将dao、service、web分开创建独立的工程则每个工程的pom.xml文件中的内容存在重复,可以将重复配置提取出来再父工程的pom.xml中定义
聚合:项目开发通常是分组分模块开发,每个模块开发完成要运行整个工程需要将每个模块聚合在一起运行

我们可以将ssh工程拆分为多个模块进行开发,包括web层、service层、dao层
1480266-20180906213158408-1571558683.png

项目结构如下:
1480266-20180906213158746-133044505.png

分模块开发的过程

1、创建父类工程,定义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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.zzh.ssh-maven</groupId>
  <artifactId>ssh-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  	<properties>
		<spring.version>4.2.4.RELEASE</spring.version>
		<hibernate.version>5.0.7.Final</hibernate.version>
		<struts.version>2.3.24</struts.version>
	</properties>

	<!-- 锁定版本,struts2-2.3.24、spring4.2.4、hibernate5.0.7 -->
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aspects</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-orm</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-test</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.hibernate</groupId>
				<artifactId>hibernate-core</artifactId>
				<version>${hibernate.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-core</artifactId>
				<version>${struts.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-spring-plugin</artifactId>
				<version>${struts.version}</version>
			</dependency>
		</dependencies>
	</dependencyManagement>
	<!-- 依赖管理 -->
	<dependencies>
		<!-- spring -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aspects</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</dependency>
		<!-- hibernate -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
		</dependency>

		<!-- 数据库驱动 -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.6</version>
			<scope>runtime</scope>
		</dependency>
		<!-- c3p0 -->

		<dependency>
			<groupId>c3p0</groupId>
			<artifactId>c3p0</artifactId>
			<version>0.9.1.2</version>
		</dependency>


		<!-- 导入 struts2 -->
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-spring-plugin</artifactId>
		</dependency>

		<!-- servlet jsp -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.0</version>
			<scope>provided</scope>
		</dependency>
		<!-- 日志 -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.7.2</version>
		</dependency>
		<!-- jstl -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>

			<plugin>  
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>  
                <configuration>  
                    <source>1.8</source>  
                    <target>1.8</target>  
                </configuration>  
            </plugin> 

			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
			</plugin>
		</plugins>
	</build>
	<modules>
		<module>ssh-dao</module>
		<module>ssh-service</module>
		<module>ssh-web</module>
	</modules>
</project>
164
 
1
<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">
2
  <modelVersion>4.0.0</modelVersion>
3
  <groupId>com.zzh.ssh-maven</groupId>
4
  <artifactId>ssh-parent</artifactId>
5
  <version>0.0.1-SNAPSHOT</version>
6
  <packaging>pom</packaging>
7
    <properties>
8
        <spring.version>4.2.4.RELEASE</spring.version>
9
        <hibernate.version>5.0.7.Final</hibernate.version>
10
        <struts.version>2.3.24</struts.version>
11
    </properties>
12
 
          
13
    <!-- 锁定版本,struts2-2.3.24、spring4.2.4、hibernate5.0.7 -->
14
    <dependencyManagement>
15
        <dependencies>
16
            <dependency>
17
                <groupId>org.springframework</groupId>
18
                <artifactId>spring-context</artifactId>
19
                <version>${spring.version}</version>
20
            </dependency>
21
            <dependency>
22
                <groupId>org.springframework</groupId>
23
                <artifactId>spring-aspects</artifactId>
24
                <version>${spring.version}</version>
25
            </dependency>
26
            <dependency>
27
                <groupId>org.springframework</groupId>
28
                <artifactId>spring-orm</artifactId>
29
                <version>${spring.version}</version>
30
            </dependency>
31
            <dependency>
32
                <groupId>org.springframework</groupId>
33
                <artifactId>spring-test</artifactId>
34
                <version>${spring.version}</version>
35
            </dependency>
36
            <dependency>
37
                <groupId>org.springframework</groupId>
38
                <artifactId>spring-web</artifactId>
39
                <version>${spring.version}</version>
40
            </dependency>
41
            <dependency>
42
                <groupId>org.hibernate</groupId>
43
                <artifactId>hibernate-core</artifactId>
44
                <version>${hibernate.version}</version>
45
            </dependency>
46
            <dependency>
47
                <groupId>org.apache.struts</groupId>
48
                <artifactId>struts2-core</artifactId>
49
                <version>${struts.version}</version>
50
            </dependency>
51
            <dependency>
52
                <groupId>org.apache.struts</groupId>
53
                <artifactId>struts2-spring-plugin</artifactId>
54
                <version>${struts.version}</version>
55
            </dependency>
56
        </dependencies>
57
    </dependencyManagement>
58
    <!-- 依赖管理 -->
59
    <dependencies>
60
        <!-- spring -->
61
        <dependency>
62
            <groupId>org.springframework</groupId>
63
            <artifactId>spring-context</artifactId>
64
        </dependency>
65
        <dependency>
66
            <groupId>org.springframework</groupId>
67
            <artifactId>spring-aspects</artifactId>
68
        </dependency>
69
        <dependency>
70
            <groupId>org.springframework</groupId>
71
            <artifactId>spring-orm</artifactId>
72
        </dependency>
73
        <dependency>
74
            <groupId>org.springframework</groupId>
75
            <artifactId>spring-test</artifactId>
76
        </dependency>
77
        <dependency>
78
            <groupId>org.springframework</groupId>
79
            <artifactId>spring-web</artifactId>
80
        </dependency>
81
        <!-- hibernate -->
82
        <dependency>
83
            <groupId>org.hibernate</groupId>
84
            <artifactId>hibernate-core</artifactId>
85
        </dependency>
86
 
          
87
        <!-- 数据库驱动 -->
88
        <dependency>
89
            <groupId>mysql</groupId>
90
            <artifactId>mysql-connector-java</artifactId>
91
            <version>5.1.6</version>
92
            <scope>runtime</scope>
93
        </dependency>
94
        <!-- c3p0 -->
95
 
          
96
        <dependency>
97
            <groupId>c3p0</groupId>
98
            <artifactId>c3p0</artifactId>
99
            <version>0.9.1.2</version>
100
        </dependency>
101
 
          
102
 
          
103
        <!-- 导入 struts2 -->
104
        <dependency>
105
            <groupId>org.apache.struts</groupId>
106
            <artifactId>struts2-core</artifactId>
107
        </dependency>
108
        <dependency>
109
            <groupId>org.apache.struts</groupId>
110
            <artifactId>struts2-spring-plugin</artifactId>
111
        </dependency>
112
 
          
113
        <!-- servlet jsp -->
114
        <dependency>
115
            <groupId>javax.servlet</groupId>
116
            <artifactId>servlet-api</artifactId>
117
            <version>2.5</version>
118
            <scope>provided</scope>
119
        </dependency>
120
        <dependency>
121
            <groupId>javax.servlet</groupId>
122
            <artifactId>jsp-api</artifactId>
123
            <version>2.0</version>
124
            <scope>provided</scope>
125
        </dependency>
126
        <!-- 日志 -->
127
        <dependency>
128
            <groupId>org.slf4j</groupId>
129
            <artifactId>slf4j-log4j12</artifactId>
130
            <version>1.7.2</version>
131
        </dependency>
132
        <!-- jstl -->
133
        <dependency>
134
            <groupId>javax.servlet</groupId>
135
            <artifactId>jstl</artifactId>
136
            <version>1.2</version>
137
        </dependency>
138
    </dependencies>
139
 
          
140
    <build>
141
        <plugins>
142
 
          
143
            <plugin>  
144
            <groupId>org.apache.maven.plugins</groupId>
145
            <artifactId>maven-compiler-plugin</artifactId>  
146
                <configuration>  
147
                    <source>1.8</source>  
148
                    <target>1.8</target>  
149
                </configuration>  
150
            </plugin> 
151
 
          
152
            <plugin>
153
                <groupId>org.apache.tomcat.maven</groupId>
154
                <artifactId>tomcat7-maven-plugin</artifactId>
155
                <version>2.2</version>
156
            </plugin>
157
        </plugins>
158
    </build>
159
    <modules>
160
        <module>ssh-dao</module>
161
        <module>ssh-service</module>
162
        <module>ssh-web</module>
163
    </modules>
164
</project>
2、通过install命令将父类工程发布至仓库
3、创建dao子模块
1480266-20180906213159671-797056146.png
1480266-20180906213159936-1217102240.png

此时parent工程中的,pom.xml会出现
1480266-20180906213200219-1850259585.png

同时我们可以在ssh-dao中的pom.xml中找到所继承的父类的信息
1480266-20180906213200505-1900917585.png

















转载于:https://www.cnblogs.com/zzh1997/p/9601128.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值