搭建基于springmvc+freemarker+maven的web项目

1、首先了解如何构建一个maven web项目




右击项目,选择project facets,勾选Dynamic Web Module



点击OK,该项目目录结构发生改变,成为能够部署在tomcat上的标准web应用,默认部署目录为WebContent


实际项目开发中,我们一般会重新构建maven项目结构,接下来就以新建一个基于spring+freemarker+maven的web项目frame为例


部署配置如下


loginCtrl.java

 

package com.frame.core.ctrl;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class loginCtrl {
	private static Logger log = Logger.getLogger(loginCtrl.class);
	@RequestMapping(value = "/login")
	public ModelAndView login() {
		ModelAndView mav = new ModelAndView("index");
		mav.addObject("username", "笑傲江湖");
		mav.addObject("projectName", "Freemarker框架");
		return mav;//ModelAndView mav = new ModelAndView("redirect:/index.do");index.do里面再返回视图可以重定向解决表单重复提交
	}
}

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:mvc="http://www.springframework.org/schema/mvc"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
	xmlns:task="http://www.springframework.org/schema/task" 
	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
	   		  http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd 
			http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
			http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
			http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
	<aop:aspectj-autoproxy/>
<!-- 	<aop:aspectj-autoproxy proxy-target-class='true'></aop:aspectj-autoproxy> -->
	<!-- 激活spring的注解. -->
	<context:annotation-config />
	<!-- Hibernate4 -->
	<!-- 加载资源文件 其中包含变量信息,必须在Spring配置文件的最前面加载,即第一个加载 -->
	<context:property-placeholder location="classpath:jdbc.properties,classpath:config.properties" />
	
	<!-- 开启这个配置,spring才能识别@Scheduled注解   --> 
	<task:annotation-driven scheduler="qbScheduler" mode="proxy"/>  
	<task:scheduler id="qbScheduler" pool-size="10"/>  
	<bean id="coreSessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- 扫描映射类,设置所扫描的包 -->
		<property name="packagesToScan" value="com.frame.core">
		</property>
		<property name="hibernateProperties">
			<props>
<!-- 				<prop key="hibernate.hbm2ddl.auto">update</prop> -->
				<prop key="hibernate.dialect">${dialect}</prop>
				<prop key="hibernate.show_sql">false</prop>
				<!-- <prop key="hibernate.current_session_context_class">thread</prop> -->
			</props>
		</property>
		<property name="mappingResources">
			<list>
			</list>
		</property>
<!-- 分布式事务 -->
	</bean>
		<bean id="transactionManager"
		class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="transactionManager" ref="bitronixTransactionManager" />
		<property name="userTransaction" ref="bitronixTransactionManager" />
	</bean>

	<bean id="bitronixTransactionManager" factory-method="getTransactionManager"
		class="bitronix.tm.TransactionManagerServices"
		destroy-method="shutdown" />
	<aop:config>
		<aop:advisor pointcut="execution(* com.frame..*.service.*.*(..))"
			advice-ref="coreTxAdvice" />
	</aop:config>

	<tx:advice id="coreTxAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="save*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="add*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="update*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="modify*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="del*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="start*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="stop*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="assign*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="clear*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="execute*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="do*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="set*" propagation="REQUIRED" rollback-for="Exception" />
			<tx:method name="*N" propagation="NEVER" />
   			<tx:method name="*" read-only="true"/>
		</tx:attributes>
	</tx:advice>

	<!-- 自动扫描组件,需要把controller去掉,否则影响事务管理 -->
	<context:component-scan base-package="com.frame">
		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
	</context:component-scan>
	<bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
			<property name="url">
				<value>${jdbc.url}</value>
			</property>
			<property name="user">
				<value>${jdbc.username}</value>
			</property>
			<property name="password">
				<value>${jdbc.password}</value>
			</property>
			<property name="autoReconnect">
				<value>true</value>
			</property>
			<property name="autoReconnectForConnectionPools">
				<value>true</value>
			</property>
			<property name="autoReconnectForPools">
				<value>true</value>
			</property>
			<property name="connectTimeout">
				<value>20000</value>
			</property>
		</bean>
</beans>

freemarker.properties

 

 

tag_syntax=auto_detect
template_update_delay=2
default_encoding=UTF-8
output_encoding=UTF-8
locale=zh_CN
date_format=yyyy-MM-dd
time_format=HH:mm:ss
datetime_format=yyyy-MM-dd HH:mm:ss

jdbc.properties

 

 

jdbc.username=root
jdbc.password=123456
jdbc.driverClassName=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://127.0.0.1:3306/inspect
jdbc.url=jdbc:mysql://127.0.0.1:3306/frame
#jdbc.url=jdbc:mysql://192.168.0.35:3308/fn
#jdbc.url=jdbc:mysql://10.169.114.175:3306/inspect
dialect=org.hibernate.dialect.MySQLDialect

spring-mvc.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        ">
	<context:component-scan base-package="com.frame"
		use-default-filters="false">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>
	<!-- 定义视图解析器 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="order" value="1" />
		<property name="prefix">
			<value>/views/</value>
		</property>
		<property name="suffix">
			<value>.html</value>
		</property>
	</bean>

	<!-- 设置freeMarker的配置文件路径 -->
	<bean id="freemarkerConfiguration"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="location" value="classpath:freemarker.properties" />
	</bean>

	<!-- 配置freeMarker的模板路径 -->
	<bean id="freemarkerConfig"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<!--property name="freemarkerSettings" ref="freemarkerConfiguration"/ -->

		<property name="templateLoaderPaths">
			<list>
				<value>/views/</value>
				<value>/ftl/</value>
			</list>
		</property>
		<property name="defaultEncoding" value="utf-8" />
		<property name="freemarkerVariables">
			<map>
				<entry key="xml_escape" value-ref="fmXmlEscape" />
			</map>
		</property>
		<property name="freemarkerSettings">
			<props>
				<prop key="template_update_delay">10</prop>
				<prop key="locale">zh_CN</prop>
				<prop key="datetime_format">yyyy-MM-dd</prop>
				<prop key="date_format">yyyy-MM-dd</prop>
				<prop key="number_format">#.##</prop>
				<!-- 自动导入的模板 -->
				<prop key="auto_include">head.ftl</prop>
			</props>
		</property>
	</bean>

	<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" />

	<!-- 配置freeMarker视图解析器 -->
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
		<property name="viewClass"
			value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
		<property name="contentType" value="text/html; charset=utf-8" />
		<property name="cache" value="true" />
		<property name="suffix" value=".html" />
		<property name="order" value="0" />
		<property name="exposeRequestAttributes" value="true" />
		<property name="exposeSessionAttributes" value="true" />
		<property name="exposeSpringMacroHelpers" value="true" />
		<property name="requestContextAttribute" value="request" />
	</bean>

	<!-- 主要作用于@Controller,激活该模式 下面是一种简写形式,完全可以手动配置替代这种简写形式; 它会自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 
		两个bean, 是spring MVC为@Controllers分发请求所必须的 -->
	<mvc:annotation-driven />
	<bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<!-- one of the properties available; the maximum file size in bytes -->
		<!-- <property name="maxUploadSize" value=""/> -->
	</bean>
</beans>

footer.fl

 

 

<#macro footer>
<#compress>
  <p>footer</P>
</#compress>
</#macro>

head.flt

 

 

 <#import "/spring.ftl" as spring/>
 <#include "/path.ftl"/>
 <#include "/title.ftl"/>
 <#include "/footer.ftl"/>
 <#macro head>
	<#compress>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
	<meta name="renderer" content="webkit" />
	<meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
	<title><@projName/></title>
 	<script>
		var path_="<@path/>"; 
		var user = "${username!''}";
	</script>
    <script src="<@path/>/js/jquery.min.js"></script>
</#compress>
</#macro> 
<#macro header>
 	<#compress>
 		<p style="font-size:25px;">project:<@projName/>;    path:<@path/>;    username:${username!''}</p>
 		<p style="font-size:20px;">header</p>
    </#compress>            
</#macro> 

path.flt

 

 

<#macro path>
<#compress>
${request.contextPath}
</#compress>
</#macro> 

title.flt

 

 

<#macro projName>
<#compress>
${projectName!""}
</#compress>
</#macro> 

webapp/views/index.html

 

 

<!DOCTYPE html>
<html lang="en" class="app">
<head>  
 <@head/>
</head>
<body class="">
    <@header/>
    <br/>
    <br/>
    <br/>
    <br/>
       middle
    <br/>
    <br/>
    <br/>
    <br/>
    <@footer/>
</body>
</html>

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" xmlns:web="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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Freemarker框架</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  </listener>
  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>
  <filter>
    <filter-name>CharacterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
      			classpath:spring-mvc.xml 
      		</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <filter>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <filter-class>
			org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
    <init-param>
      <param-name>sessionFactoryBeanName</param-name>
      <param-value>coreSessionFactory</param-value>
    </init-param>
    <init-param>
      <param-name>singleSession</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>flushMode</param-name>
      <param-value>AUTO</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

webapp/index.jsp

 

 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<h2><%response.sendRedirect(request.getContextPath()+"/login.do"); %></h2>
</body>
</html>

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">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.frame</groupId>
	<artifactId>frame</artifactId>
	<packaging>war</packaging>
	<version>0.0.2-SNAPSHOT</version>
	<name>Freemarker框架</name>
	<url>http://maven.apache.org</url>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit-version}</version>
		</dependency>
		
		<dependency>  
		    <groupId>com.fasterxml.jackson.core</groupId>  
		    <artifactId>jackson-databind</artifactId>  
		    <version>${jackson2.version}</version>  
		</dependency> 
		
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</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-orm</artifactId>
			<version>${spring-version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring-version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</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.data</groupId>
	        <artifactId>spring-data-jpa</artifactId>
	        <version>1.8.0.RELEASE</version>
	    </dependency> 

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring-version}</version>
<!-- 			<scope>test</scope> -->
		</dependency>

		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>${aspectjweaver-version}</version>
		</dependency>

		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib-nodep</artifactId>
			<version>${cglib-version}</version>
		</dependency>

		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
			<version>${commons-dbcp-version}</version>
		</dependency>
		<dependency>
			 <groupId>org.apache.commons</groupId>
 			 <artifactId>commons-lang3</artifactId>
			<version>${commons-lang-version}</version>
		</dependency>
	<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>${commons-fileupload-version}</version>
		</dependency>
		<!-- Hibernate 4.1.9.Final -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>${hibernate-version}</version>
		</dependency>
		<!-- MySQL Driver -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql-connector-version}</version>
		</dependency>
		<!-- log4j -->
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>${log4j-version}</version>
		</dependency>
		<dependency>  
		    <groupId>org.mortbay.jetty</groupId>  
		    <artifactId>servlet-api-2.5</artifactId>  
		    <version>6.1.14</version>
		    <scope>provided</scope>  
		</dependency> 
		<dependency>
			  <groupId>org.freemarker</groupId>
			  <artifactId>freemarker</artifactId>
			  <version>${freemarker-version}</version>
			</dependency>
		<dependency>
		     <groupId>org.apache.tomcat</groupId>
			  <artifactId>tomcat-servlet-api</artifactId>
			  <version>7.0.47</version>
		    <scope>provided</scope>
		</dependency>
			<dependency>
			<groupId>opensymphony</groupId>
			<artifactId>oscache</artifactId>
			<version>${oscache-version}</version>
		</dependency>
		
		<dependency> 
		    <groupId>json</groupId>
			<artifactId>org.json-2.0.jar</artifactId>
			<version>2.0</version>
		    <scope>system</scope>
		    <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/org.json-2.0.jar</systemPath>
		</dependency>
		
		<dependency>
			<groupId>org.quartz-scheduler</groupId>
			<artifactId>quartz</artifactId>
			<version>2.2.1</version>
		</dependency>
 
	    <dependency>
	      <groupId>com.thoughtworks.xstream</groupId>
	      <artifactId>xstream</artifactId>
	      <version>1.4.7</version>
	    </dependency>
	    
		    <dependency>
		      <groupId>org.codehaus.btm</groupId>
		      <artifactId>btm</artifactId>
			<version>2.1.4</version>
		    </dependency>
		    
		    <dependency>
		       <groupId>org.jboss.spec.javax.el</groupId>
			  <artifactId>jboss-el-api_2.2_spec</artifactId>
			  <version>1.0.4.Final</version>
			  <scope>provided</scope>
		    </dependency>
		    
		    <dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-web</artifactId>
					  <version>${spring.security.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-config</artifactId>
					  <version>${spring.security.version}</version>
			</dependency>
			<dependency>
				<groupId>jaxen</groupId>
				<artifactId>jaxen</artifactId>
				<version>1.1.6</version>
			</dependency>
			<dependency>
				<groupId>net.sf.json-lib</groupId>
				<artifactId>json-lib</artifactId>
				<version>2.2.3</version>
				<classifier>jdk15</classifier>
			</dependency>
	</dependencies>
	<build>
		<finalName>frame</finalName>
      <sourceDirectory>src/main/java</sourceDirectory>
      <testSourceDirectory>src/test/java</testSourceDirectory>
      <resources>
          <resource>
             <directory>src/main/resources</directory>
           </resource>
          <resource>
             <directory>src/jbpm/resources</directory>
           </resource>
          <resource>
             <directory>src/main/config</directory>
           </resource>
       </resources>
      <testResources>
          <testResource>
             <directory>src/test/resources</directory>
           </testResource>
       </testResources>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.0</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<warSourceDirectory>src/main/webapp</warSourceDirectory>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>
			
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<port>8080</port>
					<path>/frame</path>
					<url>http://localhost:8080/manager/html</url>
					<server>tomcat</server>
					<username>admin</username>
					<password>admin</password>
					<server>tomcat7</server>
                </configuration>
				<dependencies>
					<dependency>
						<groupId>mysql</groupId>
						<artifactId>mysql-connector-java</artifactId>
						<version>${mysql-connector-version}</version>
					</dependency>
					<dependency>
						<groupId>org.codehaus.btm</groupId>
						<artifactId>btm</artifactId>
						<version>${btm.version}</version>
					</dependency>
					<dependency>
						<groupId>org.codehaus.btm</groupId>
						<artifactId>btm-tomcat55-lifecycle</artifactId>
						<version>${btm.version}</version>
					</dependency>
					<dependency>
						<artifactId>slf4j-api</artifactId>
						<groupId>org.slf4j</groupId>
						<version>1.7.2</version>
					</dependency>
					<dependency>
						<groupId>javax.transaction</groupId>
						<artifactId>jta</artifactId>
						<version>1.1</version>
					</dependency>
					<dependency>
						<groupId>com.h2database</groupId>
						<artifactId>h2</artifactId>
						<version>1.3.168</version>
					</dependency>
				</dependencies>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.17</version>
				<configuration>
					<includes>
						<include>
							**/*Test.java
						</include>
					</includes>
					<excludes>
					 	<exclude>
							**/*AllTest.java
					 	</exclude>
					 	<exclude>
							**/AControllerTest.java 
					 	</exclude>
					</excludes>
					<systemPropertyVariables>
						<propertyName>firefox</propertyName>
						<suiteXmlFile>testng.xml</suiteXmlFile>
					</systemPropertyVariables>
				</configuration>
			</plugin>
			<plugin>
		        <groupId>org.codehaus.mojo</groupId>
		        <artifactId>build-helper-maven-plugin</artifactId>
		        <version>1.4</version>
		        <executions>
		          <execution>
		            <id>add-source</id>
		            <phase>generate-sources</phase>
		            <goals>
		              <goal>add-source</goal>
		            </goals>
		            <configuration>
		              <sources>
		                <source>src/main/java</source>
		              </sources>
		            </configuration>
		          </execution>
		        </executions>
		      </plugin>
	</plugins>
	<pluginManagement>
			<plugins>
				<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>
											org.codehaus.mojo
										</groupId>
										<artifactId>
											build-helper-maven-plugin
										</artifactId>
										<versionRange>
											[1.4,)
										</versionRange>
										<goals>
											<goal>add-source</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore></ignore>
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
		<copyright.year>2014</copyright.year>
		<spring-version>4.0.9.RELEASE</spring-version>
		<spring.security.version>3.2.0.RELEASE</spring.security.version>
		<hibernate-version>4.2.17.Final</hibernate-version>
		<hibernate-search-version>4.2.0.Beta2</hibernate-search-version>
		<struts-version>2.3.8</struts-version>
		<commons-dbcp-version>1.4</commons-dbcp-version>
		<commons-lang-version>3.3.2</commons-lang-version>
		<cglib-version>2.2.2</cglib-version>
		<aspectjweaver-version>1.7.1</aspectjweaver-version>
		<jstl-version>1.2</jstl-version>
		<servlet-version>3.0-alpha-1</servlet-version>
		<jsp-version>2.2.1-b03</jsp-version>
		<guava-version>13.0.1</guava-version>
		<slf4j-nop-version>1.7.2</slf4j-nop-version>
		<log4j-version>1.2.17</log4j-version>
		<junit-version>4.11</junit-version>
		<mysql-connector-version>5.1.22</mysql-connector-version>
		<testng-version>6.1.1</testng-version>
		<freemarker-version>2.3.20</freemarker-version>
		<javaee-version>6.0</javaee-version>
		<jsonpath.version>0.9.0</jsonpath.version>
		<jackson2.version>2.2.3</jackson2.version>
		<commons-fileupload-version>1.3.1</commons-fileupload-version> 
		<oscache-version>2.3</oscache-version> 
	    <version.org.drools>6.0.0.Final</version.org.drools>
	    <version.org.jbpm>6.0.0.Final</version.org.jbpm>
	    <jboss.javaee.version>1.0.0.Final</jboss.javaee.version>
	    <logback.version>1.0.9</logback.version>
	    <h2.version>1.3.161</h2.version>
	    <btm.version>2.1.4</btm.version>
	    <junit.version>4.8.1</junit.version>
		 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
</project>

运行效果

 
















 

posted @ 2016-09-26 00:01  海的心  阅读(216)  评论(0编辑  收藏  举报