maven學習使用 下

一、使用maven構建SSH項目:

1、創建一個maven項目,目錄結構如下:
在這裏插入圖片描述
2、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>cn.itcast.maven</groupId>
	<artifactId>maven_web</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	
	<!-- spring依賴 -->
	<dependencies>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
		</dependency>
		<dependency>
			<groupId>antlr</groupId>
			<artifactId>antlr</artifactId>
		</dependency>
		<dependency>
			<groupId>c3p0</groupId>
			<artifactId>c3p0</artifactId>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aspects</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</dependency>
		<!-- struts2依賴 -->
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-core</artifactId>
			<!-- 排除傳遞的依賴 -->
			<exclusions>
				<exclusion>
					<artifactId>javassist</artifactId>
					<groupId>javassist</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-json-plugin</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-spring-plugin</artifactId>
		</dependency>
		<!-- cxf依賴 -->
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jsp-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>net.sf.json-lib</groupId>
			<artifactId>json-lib</artifactId>
			<classifier>jdk15</classifier>
		</dependency>
		<!-- 引入shiro框架的依賴 -->
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-all</artifactId>
		</dependency>
		<!-- <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> 
			</dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> 
			</dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> 
			</dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-aspectj</artifactId> 
			</dependency> -->
		<dependency>
			<groupId>com.belerweb</groupId>
			<artifactId>pinyin4j</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
		</dependency>
		<!-- 引入ehcache的依賴 -->
		<dependency>
			<groupId>net.sf.ehcache</groupId>
			<artifactId>ehcache-core</artifactId>
		</dependency>
	</dependencies>

	<properties>
		<org.springframework.version>4.2.4.RELEASE</org.springframework.version>
		<org.apache.struts.version>2.3.24</org.apache.struts.version>
		<asm.version>3.3</asm.version>
		<hibernate.version>5.0.7.Final</hibernate.version>
		<shiro.version>1.2.3</shiro.version>
		<antlr.version>2.7.6</antlr.version>
		<c3p0.version>0.9.1</c3p0.version>
		<mysql.version>5.1.39</mysql.version>
		<cxf.version>3.0.1</cxf.version>
	</properties>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>antlr</groupId>
				<artifactId>antlr</artifactId>
				<version>${antlr.version}</version>
			</dependency>
			<dependency>
				<groupId>c3p0</groupId>
				<artifactId>c3p0</artifactId>
				<version>${c3p0.version}</version>
			</dependency>
			<dependency>
				<groupId>mysql</groupId>
				<artifactId>mysql-connector-java</artifactId>
				<version>${mysql.version}</version>
			</dependency>
			<dependency>
				<groupId>org.hibernate</groupId>
				<artifactId>hibernate-core</artifactId>
				<version>${hibernate.version}</version>
			</dependency>
			<!-- spring依賴 -->
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aop</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aspects</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-beans</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-core</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-expression</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-jdbc</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-orm</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-tx</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-tx</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<!-- struts2依賴 -->
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-core</artifactId>
				<version>${org.apache.struts.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-json-plugin</artifactId>
				<version>${org.apache.struts.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-spring-plugin</artifactId>
				<version>${org.apache.struts.version}</version>
			</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>
			<dependency>
				<groupId>net.sf.json-lib</groupId>
				<artifactId>json-lib</artifactId>
				<version>2.4</version>
				<classifier>jdk15</classifier>
			</dependency>
			<!-- cxf依賴 -->
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-frontend-jaxws</artifactId>
				<version>${cxf.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-transports-http</artifactId>
				<version>${cxf.version}</version>
			</dependency>
			<!-- shiro -->
			<!-- apache shiro dependencies -->
			<dependency>
				<groupId>org.apache.shiro</groupId>
				<artifactId>shiro-all</artifactId>
				<version>${shiro.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.shiro</groupId>
				<artifactId>shiro-core</artifactId>
				<version>${shiro.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.shiro</groupId>
				<artifactId>shiro-web</artifactId>
				<version>${shiro.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.shiro</groupId>
				<artifactId>shiro-spring</artifactId>
				<version>${shiro.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.shiro</groupId>
				<artifactId>shiro-aspectj</artifactId>
				<version>${shiro.version}</version>
			</dependency>
			<dependency>
				<groupId>com.belerweb</groupId>
				<artifactId>pinyin4j</artifactId>
				<version>2.5.0</version>
			</dependency>
			<dependency>
				<groupId>org.apache.poi</groupId>
				<artifactId>poi</artifactId>
				<version>3.14</version>
			</dependency>
			<!-- 引入ehcache的依賴 -->
			<dependency>
				<groupId>net.sf.ehcache</groupId>
				<artifactId>ehcache-core</artifactId>
				<version>2.6.6</version>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<configuration>
					<port>8080</port>
					<path>/maven_web</path> <!-- 此處的名字是項目發佈的工程名 -->
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
					<encoding>utf8</encoding>
				</configuration>
			</plugin>
		</plugins>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
		</resources>
	</build>
</project>

3、web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <display-name>maven_web</display-name>
		  
		  <!-- 配置spring容器的位置 -->
		  <context-param>
		  	<param-name>contextConfigLocation</param-name>
		  	<param-value>classpath:applicationContext.xml</param-value>
		  </context-param>
		  <!-- 配置spring監聽器 -->
		  <listener>
		  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
		  </listener>
		  <!-- 配置struts過濾器 -->
		  <filter>
		  	<filter-name>struts2</filter-name>
		  	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
		  </filter>
		  <filter-mapping>
		  	<filter-name>struts2</filter-name>
		  	<url-pattern>/*</url-pattern>
		  </filter-mapping>
		  <welcome-file-list>
		    <welcome-file>index.html</welcome-file>
		    <welcome-file>index.htm</welcome-file>
		    <welcome-file>index.jsp</welcome-file>
		    <welcome-file>default.html</welcome-file>
		    <welcome-file>default.htm</welcome-file>
		    <welcome-file>default.jsp</welcome-file>
		  </welcome-file-list>
		</web-app>   

4、struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">

	<struts>
	  <constant name="struts.devMode" value="false"/>
	  <package name="basicstruts2" extends="struts-default">
	    <action name="userAction_*" 
	    	class="userAction" method="{1}">
	    	<result name="list">/jsp/test.jsp</result>
	    </action>
	  </package>
	</struts>   

5、applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans.xsd
						http://www.springframework.org/schema/context
						http://www.springframework.org/schema/context/spring-context.xsd
						http://www.springframework.org/schema/aop
						http://www.springframework.org/schema/aop/spring-aop.xsd
						http://www.springframework.org/schema/tx 
						http://www.springframework.org/schema/tx/spring-tx.xsd">
	<!-- 配置數據源  -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="com.mysql.jdbc.Driver"/>
		<property name="jdbcUrl" value="jdbc:mysql:///demo1"/>
		<property name="user" value="root"/>
		<property name="password" value="admin"/>
	</bean>
	<!-- 配置spring整合hibernate的session工廠 -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<!-- 配置數據源 -->
		<property name="dataSource" ref="dataSource"/>
		<!-- 配置hibernate的基本屬性 -->
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
			</props>
		</property>
		<!-- 配置hibernate實體類的映射文件 -->
		<property name="mappingLocations">
			<array>
				<value>classpath:cn/itcast/maven/domain/*.hbm.xml</value>
			</array>
		</property>
	</bean>
	
	<!-- 配置UserDao -->
	<bean id="userDao" class="cn.itcast.maven.dao.impl.UserDaoImpl">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
	
	<!-- 配置UserService -->
	<bean id="userService" class="cn.itcast.maven.service.impl.UserServiceImpl">
		<property name="userDao" ref="userDao"/>
	</bean>
	
	<!-- 配置UserActionbean -->
	<bean id="userAction" class="cn.itcast.maven.web.action.UserAction" scope="prototype">
		<property name="userService" ref="userService"/>
	</bean>
</beans>   

二、分模塊構建項目:

1、首先創建一個maven_parent工程
在這裏插入圖片描述
2、然後在maven_parent基礎上,按層分的話,依次創建dao,service,web
在這裏插入圖片描述
maven_parent的pom.xml爲配置有項目依賴的jar包

 <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>cn.itcast.maven</groupId>
	  <artifactId>maven_parent</artifactId>
	  <version>0.0.1-SNAPSHOT</version>
	  <packaging>pom</packaging>
	  <!-- spring依賴 -->
		<dependencies>
			<dependency>
				<groupId>mysql</groupId>
				<artifactId>mysql-connector-java</artifactId>
			</dependency>
			<dependency>
				<groupId>antlr</groupId>
				<artifactId>antlr</artifactId>
			</dependency>
			<dependency>
				<groupId>c3p0</groupId>
				<artifactId>c3p0</artifactId>
			</dependency>
			<dependency>
				<groupId>org.hibernate</groupId>
				<artifactId>hibernate-core</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aop</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aspects</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-beans</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-core</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-expression</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-jdbc</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-orm</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-tx</artifactId>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
			</dependency>
			<!-- struts2依賴 -->
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-core</artifactId>
				<!-- 排除傳遞的依賴 -->
				<exclusions>
					<exclusion>
						<artifactId>javassist</artifactId>
						<groupId>javassist</groupId>
					</exclusion>
				</exclusions>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-json-plugin</artifactId>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-spring-plugin</artifactId>
			</dependency>
			<!-- cxf依賴 -->
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-frontend-jaxws</artifactId>
			</dependency>
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-transports-http</artifactId>
			</dependency>
			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>servlet-api</artifactId>
				<scope>provided</scope>
			</dependency>
			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>jsp-api</artifactId>
				<scope>provided</scope>
			</dependency>
			<dependency>
				<groupId>net.sf.json-lib</groupId>
				<artifactId>json-lib</artifactId>
				<classifier>jdk15</classifier>
			</dependency>
			<!-- 引入shiro框架的依賴 -->
			<dependency>
				<groupId>org.apache.shiro</groupId>
				<artifactId>shiro-all</artifactId>
			</dependency>
			<!-- <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> 
				</dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> 
				</dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> 
				</dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-aspectj</artifactId> 
				</dependency> -->
			<dependency>
				<groupId>com.belerweb</groupId>
				<artifactId>pinyin4j</artifactId>
			</dependency>
			<dependency>
				<groupId>org.apache.poi</groupId>
				<artifactId>poi</artifactId>
			</dependency>
			<!-- 引入ehcache的依賴 -->
			<dependency>
				<groupId>net.sf.ehcache</groupId>
				<artifactId>ehcache-core</artifactId>
			</dependency>
		</dependencies>
	
		<properties>
			<org.springframework.version>4.2.4.RELEASE</org.springframework.version>
			<org.apache.struts.version>2.3.24</org.apache.struts.version>
			<asm.version>3.3</asm.version>
			<hibernate.version>5.0.7.Final</hibernate.version>
			<shiro.version>1.2.3</shiro.version>
			<antlr.version>2.7.6</antlr.version>
			<c3p0.version>0.9.1</c3p0.version>
			<mysql.version>5.1.39</mysql.version>
			<cxf.version>3.0.1</cxf.version>
		</properties>
		<dependencyManagement>
			<dependencies>
				<dependency>
					<groupId>antlr</groupId>
					<artifactId>antlr</artifactId>
					<version>${antlr.version}</version>
				</dependency>
				<dependency>
					<groupId>c3p0</groupId>
					<artifactId>c3p0</artifactId>
					<version>${c3p0.version}</version>
				</dependency>
				<dependency>
					<groupId>mysql</groupId>
					<artifactId>mysql-connector-java</artifactId>
					<version>${mysql.version}</version>
				</dependency>
				<dependency>
					<groupId>org.hibernate</groupId>
					<artifactId>hibernate-core</artifactId>
					<version>${hibernate.version}</version>
				</dependency>
				<!-- spring依賴 -->
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-aop</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-aspects</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-beans</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-context</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-core</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-expression</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-jdbc</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-orm</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-tx</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-tx</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<dependency>
					<groupId>org.springframework</groupId>
					<artifactId>spring-web</artifactId>
					<version>${org.springframework.version}</version>
				</dependency>
				<!-- struts2依賴 -->
				<dependency>
					<groupId>org.apache.struts</groupId>
					<artifactId>struts2-core</artifactId>
					<version>${org.apache.struts.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.struts</groupId>
					<artifactId>struts2-json-plugin</artifactId>
					<version>${org.apache.struts.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.struts</groupId>
					<artifactId>struts2-spring-plugin</artifactId>
					<version>${org.apache.struts.version}</version>
				</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>
				<dependency>
					<groupId>net.sf.json-lib</groupId>
					<artifactId>json-lib</artifactId>
					<version>2.4</version>
					<classifier>jdk15</classifier>
				</dependency>
				<!-- cxf依賴 -->
				<dependency>
					<groupId>org.apache.cxf</groupId>
					<artifactId>cxf-rt-frontend-jaxws</artifactId>
					<version>${cxf.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.cxf</groupId>
					<artifactId>cxf-rt-transports-http</artifactId>
					<version>${cxf.version}</version>
				</dependency>
				<!-- shiro -->
				<!-- apache shiro dependencies -->
				<dependency>
					<groupId>org.apache.shiro</groupId>
					<artifactId>shiro-all</artifactId>
					<version>${shiro.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.shiro</groupId>
					<artifactId>shiro-core</artifactId>
					<version>${shiro.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.shiro</groupId>
					<artifactId>shiro-web</artifactId>
					<version>${shiro.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.shiro</groupId>
					<artifactId>shiro-spring</artifactId>
					<version>${shiro.version}</version>
				</dependency>
				<dependency>
					<groupId>org.apache.shiro</groupId>
					<artifactId>shiro-aspectj</artifactId>
					<version>${shiro.version}</version>
				</dependency>
				<dependency>
					<groupId>com.belerweb</groupId>
					<artifactId>pinyin4j</artifactId>
					<version>2.5.0</version>
				</dependency>
				<dependency>
					<groupId>org.apache.poi</groupId>
					<artifactId>poi</artifactId>
					<version>3.14</version>
				</dependency>
				<!-- 引入ehcache的依賴 -->
				<dependency>
					<groupId>net.sf.ehcache</groupId>
					<artifactId>ehcache-core</artifactId>
					<version>2.6.6</version>
				</dependency>
			</dependencies>
		</dependencyManagement>
	
		<build>
			<plugins>
				<plugin>
					<groupId>org.apache.tomcat.maven</groupId>
					<artifactId>tomcat7-maven-plugin</artifactId>
					<configuration>
						<port>8080</port>
						<path>/maven_web</path> <!-- 此處的名字是項目發佈的工程名 -->
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<source>1.7</source>
						<target>1.7</target>
						<encoding>utf8</encoding>
					</configuration>
				</plugin>
			</plugins>
			<resources>
				<resource>
					<directory>src/main/java</directory>
					<includes>
						<include>**/*.properties</include>
						<include>**/*.xml</include>
					</includes>
					<filtering>false</filtering>
				</resource>
				<resource>
					<directory>src/main/resources</directory>
					<includes>
						<include>**/*.properties</include>
						<include>**/*.xml</include>
					</includes>
					<filtering>false</filtering>
				</resource>
			</resources>
		</build>
		<modules>
			<module>maven_parent_web</module>
			<module>maven_parent_service</module>
			<module>maven_parent_dao</module>
		</modules>
	</project>

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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>cn.itcast.maven</groupId>
		<artifactId>maven_parent</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<artifactId>maven_parent_web</artifactId>
	<packaging>war</packaging>
	<dependencies>
		<dependency>
			<groupId>cn.itcast.maven</groupId>
			<artifactId>maven_parent_service</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
	</dependencies>
</project> 

同時,將applicationContext.xml,struts.xml也配置在web的resource下

service的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>
	  <parent>
	    <groupId>cn.itcast.maven</groupId>
	    <artifactId>maven_parent</artifactId>
	    <version>0.0.1-SNAPSHOT</version>
	  </parent>
	  <artifactId>maven_parent_service</artifactId>
	  <dependencies>
	  	<dependency>
	  		<groupId>cn.itcast.maven</groupId>
	  		<artifactId>maven_parent_dao</artifactId>
	  		<version>0.0.1-SNAPSHOT</version>
	  	</dependency>
	  </dependencies>
	</project>   

dao的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>
  <parent>
    <groupId>cn.itcast.maven</groupId>
    <artifactId>maven_parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>maven_parent_dao</artifactId>
</project>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章