使用maven在项目中包含最新版本的spring和hibernate

时间:2015-03-16 06:39:23

标签: maven

如何使用maven在项目中包含spring和hibernate的最新版本,需要在pom文件中添加所有依赖项。

2 个答案:

答案 0 :(得分: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/maven-v4_0_0.xsd">  
 <modelVersion>4.0.0</modelVersion>  
 <groupId>com.test</groupId>  
 <artifactId>SpringHibernateAnnotations</artifactId>  
 <packaging>war</packaging>  
 <version>1.0-SNAPSHOT</version>  
 <name>SpringHibernateAnnotations Maven Webapp</name>  
 <url>http://maven.apache.org</url>  

 <properties>  
  <spring.version>4.0.5.RELEASE</spring.version>  
  <hibernate.version>4.3.5.Final</hibernate.version>  
  <log4j.version>1.2.17</log4j.version>  
  <jdk.version>1.7</jdk.version>  
  <context.path>SpringHibernateAnnotations</context.path>  
 </properties>  


 <build>  
  <finalName>${pom.artifactId}</finalName>  

  <plugins>  
   <!-- Maven compiler plugin -->  
   <plugin>  
    <artifactId>maven-compiler-plugin</artifactId>  
    <configuration>  
     <source>${jdk.version}</source>  
     <target>${jdk.version}</target>  
    </configuration>  
   </plugin>  
  </plugins>  
 </build>  
 <dependencies>  
  <dependency>  
   <groupId>log4j</groupId>  
   <artifactId>log4j</artifactId>  
   <version>${log4j.version}</version>  
  </dependency>  

  <dependency>  
   <groupId>org.springframework</groupId>  
   <artifactId>spring-orm</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-web</artifactId>  
   <version>${spring.version}</version>  
  </dependency>  

  <dependency>  
   <groupId>org.hibernate</groupId>  
   <artifactId>hibernate-entitymanager</artifactId>  
   <version>${hibernate.version}</version>  
  </dependency>  

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

  <dependency>  
   <groupId>jstl</groupId>  
   <artifactId>jstl</artifactId>  
   <version>1.2</version>  
  </dependency>  
  <dependency>  
   <groupId>mysql</groupId>  
   <artifactId>mysql-connector-java</artifactId>  
   <version>5.1.6</version>  
  </dependency>  


 </dependencies>  
</project>  

您可以根据自己的要求更改版本。

答案 1 :(得分:0)

转到Maven Central Search,搜索Spring和Hibernate并找到最新版本。