1. 程式人生 > >maven整合ssm框架pom.xml配置檔案

maven整合ssm框架pom.xml配置檔案

這裡直接貼出整合後的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.cyn.maven.ssm</groupId>
  <artifactId>maven_ssm</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  
  <!-- 定義版本常量 -->
  <properties>
  	<!-- spring版本號 -->
  	<spring.version>4.2.4.RELEASE</spring.version>
  	<!-- mybatis版本號 -->
  	<mybatis.version>3.4.6</mybatis.version>
  	<!-- log4j日誌版本號 -->
  	<slf4j.version>1.6.6</slf4j.version>  
    <log4j.version>1.2.17</log4j.version> 
  </properties>
  
  <!-- 版本鎖定:專案拆分聚合中由父專案指定  -->
  <!-- <dependencyManagement>
  	<dependencies>
		<dependency>
			<groupId>junit</groupId>
		  	<artifactId>junit</artifactId>
		  	<version>4.12</version>
		  	<scope>test</scope>
	  	</dependency>
	</dependencies>
  </dependencyManagement> -->
 
  <dependencies>
  	<!-- servlet -->
	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>servlet-api</artifactId>
		<version>2.5</version>
		<scope>provided</scope>
	</dependency>
	
	<!-- 編譯jsp頁面 -->
	<dependency>
		<groupId>javax.servlet.jsp</groupId>
		<artifactId>jsp-api</artifactId>
		<version>2.0</version>
		<scope>provided</scope>
	</dependency>
  	
	<!-- 匯入mysql資料庫連結jar包 -->
	<dependency>
    	<groupId>mysql</groupId>
    	<artifactId>mysql-connector-java</artifactId>
    	<version>5.1.18</version>
	</dependency>
	
	<!-- 匯入dbcp的jar包,用來在連線池中配置資料庫 -->
	<dependency>
    	<groupId>commons-dbcp</groupId>
    	<artifactId>commons-dbcp</artifactId>
    	<version>1.2.2</version>
	</dependency>
	<!-- 連線池 -->
	<dependency>
    	<groupId>commons-pool</groupId>
    	<artifactId>commons-pool</artifactId>
    	<version>1.6</version>
	</dependency>

	<!-- spring -->
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-web</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-tx</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-jdbc</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-context-support</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-test</artifactId>
    	<version>${spring.version}</version>
    	<!-- <scope>test</scope> -->
	</dependency>
	
	<!-- aop -->
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-aspects</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.aspectj</groupId>
    	<artifactId>aspectjweaver</artifactId>
    	<version>1.8.13</version>
	</dependency>
	
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-messaging</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-jms</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-expression</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	
	<!-- springmvc -->
	<dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-webmvc</artifactId>
    	<version>${spring.version}</version>
	</dependency>
	
	<!-- mybatis -->
  	<dependency>
    	<groupId>org.mybatis</groupId>
    	<artifactId>mybatis</artifactId>
    	<version>${mybatis.version}</version>
	</dependency>
	
	<!-- mybatis和spring整合 -->
  	<dependency>
    	<groupId>org.mybatis</groupId>
    	<artifactId>mybatis-spring</artifactId>
    	<version>1.2.2</version>
	</dependency>
		
	<!-- log4j日誌檔案管理包 -->
	<dependency>
    	<groupId>org.apache.logging.log4j</groupId>
    	<artifactId>log4j-core</artifactId>
    	<version>2.8.2</version>
	</dependency>
	<dependency>
    	<groupId>log4j</groupId>
    	<artifactId>log4j</artifactId>
    	<version>${log4j.version}</version>
	</dependency>
	
	<dependency>
    	<groupId>org.slf4j</groupId>
    	<artifactId>slf4j-api</artifactId>
    	<version>${slf4j.version}</version>
	</dependency>
	<dependency>
    	<groupId>org.slf4j</groupId>
    	<artifactId>slf4j-log4j12</artifactId>
    	<version>${slf4j.version}</version>
    	<scope>test</scope>
	</dependency>
	
	<!-- junit測試 -->
	<dependency>
    	<groupId>junit</groupId>
    	<artifactId>junit</artifactId>
    	<version>4.12</version>
    	<scope>test</scope>
	</dependency>
	
	<!-- jstl標籤庫 -->
	<dependency>
    	<groupId>javax.servlet</groupId>
    	<artifactId>jstl</artifactId>
    	<version>1.2</version>
	</dependency>
	
	<!-- 匯入json -->
	<dependency>
   		<groupId>org.json</groupId>
    	<artifactId>json</artifactId>
    	<version>20160810</version>
	</dependency>

	<dependency>
    	<groupId>com.fasterxml.jackson.core</groupId>
    	<artifactId>jackson-databind</artifactId>
    	<version>2.9.5</version>
	</dependency>
	
	<!-- 檔案上傳 -->
	<dependency>
    	<groupId>commons-io</groupId>
    	<artifactId>commons-io</artifactId>
    	<version>2.4</version>
	</dependency>
	<dependency>
    	<groupId>commons-fileupload</groupId>
    	<artifactId>commons-fileupload</artifactId>
    	<version>1.2.2</version>
	</dependency>
	<dependency>
   		<groupId>commons-codec</groupId>
    	<artifactId>commons-codec</artifactId>
    	<version>1.10</version>
	</dependency>
	
	<!-- 其他 -->
	<dependency>
    	<groupId>dom4j</groupId>
    	<artifactId>dom4j</artifactId>
    	<version>1.6.1</version>
	</dependency>
	
	<dependency>
    	<groupId>org.apache.commons</groupId>
    	<artifactId>commons-lang3</artifactId>
    	<version>3.4</version>
	</dependency>
	
	<dependency>
    	<groupId>commons-collections</groupId>
    	<artifactId>commons-collections</artifactId>
    	<version>3.2.1</version>
	</dependency>
	
	<dependency>
    	<groupId>cglib</groupId>
    	<artifactId>cglib</artifactId>
    	<version>2.2</version>
	</dependency>
	
	<dependency>
    	<groupId>org.hamcrest</groupId>
    	<artifactId>hamcrest-core</artifactId>
    	<version>1.3</version>
    	<scope>test</scope>
	</dependency>
	
	<dependency>
    	<groupId>taglibs</groupId>
    	<artifactId>standard</artifactId>
    	<version>1.1.2</version>
	</dependency>
  </dependencies>
  
	<!-- 匯入外掛 -->
	<build>
		<!-- 內建tomcat -->
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<!-- 訪問埠 -->
					<port>8080</port>
					<!-- 專案路徑 -->
					<path>/maven_ssm</path>
					<!-- 指定編碼 -->
					<uriEncoding>utf-8</uriEncoding>
				</configuration>
			</plugin>
			<!-- 編譯 -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<!-- 原始碼版本 -->
					<source>1.8</source>
					<!-- 編譯目標版本 -->
					<target>1.8</target>
					<!-- 指定編碼 -->
					<!-- <encoding>utf-8</encoding> -->
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

最後再記錄下,自己整合過程中遇到的問題:

1.當使用eclipse構造web-maven專案後pom.xml檔案報錯

  • 在webapp下構建標準web工程目錄,包括WEB-INF、web.xml

2.jsp頁面報錯

  • 在pom.xml檔案中新增編譯jsp頁面的jar包,依賴範圍為provided

3.當啟動專案出現spring監聽器錯誤時候,說明缺少lib資料夾,具體做法請百度!

4.每次改變pox.xml檔案,都點選專案右鍵Maven->Update Project進行重新整理,例如:更新jdk、tomcat等