直须看尽洛城花 2013-09-14
最近公司要求搭建一个jersey 2 +spring 3.1.0.RELEASE+hibernate 3.3.1.GA 的平台项目,费了九牛二虎之力终于把冲突包去掉,搭建完成,这里把maven配置文件发布出来供大家吐槽一下。
<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>ysb.xxx</groupId> <artifactId>platform</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>platform Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <org.springframework.version>3.1.0.RELEASE</org.springframework.version> <org.hibernate.version>3.3.1.GA</org.hibernate.version> <org.hibernate.entitymanager.version>3.4.0.GA</org.hibernate.entitymanager.version> <connect.mysql.java.version>5.1.26</connect.mysql.java.version> <org.slf4j-version>1.6.1</org.slf4j-version> <com.sun.jersey.version>2.2</com.sun.jersey.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>${com.sun.jersey.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-spring3</artifactId> <version>${com.sun.jersey.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-orm</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- 添加hibernate 支持 --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${org.hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>${org.hibernate.version}</version> <exclusions> <exclusion> <artifactId>asm-attrs</artifactId> <groupId>asm</groupId> </exclusion> <exclusion> <artifactId>asm</artifactId> <groupId>asm</groupId> </exclusion> <exclusion> <artifactId>cglib</artifactId> <groupId>cglib</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${org.hibernate.entitymanager.version}</version> </dependency> <!-- 添加mysql 支持 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${connect.mysql.java.version}</version> </dependency> <!-- 添加dbcp支持 --> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.7.2</version> </dependency> </dependencies> <build> <finalName>platform</finalName> </build> </project>
web.xml配置如下
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</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> <servlet> <servlet-name>SpringApplication</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.{xx}.controllers</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SpringApplication</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>