2016-08-15 82 views
0

我只是想知道使用hibernate需要哪些依賴關係?我在我的POM找不到類 - hibernate5 LocalSessionFactoryBean

<dependencies> 
     <dependency> 
      <groupId>org.glassfish.jersey.containers</groupId> 
      <artifactId>jersey-container-servlet</artifactId> 
      <version>2.23.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>4.3.2.RELEASE</version> 
      <scope>compile</scope> 
     </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>2.23.1</version> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>4.3.2.RELEASE</version> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds --> 
     <dependency> 
      <groupId>net.sourceforge.jtds</groupId> 
      <artifactId>jtds</artifactId> 
      <version>1.3.1</version> 
     </dependency> 



     <!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp --> 
     <dependency> 
      <groupId>commons-dbcp</groupId> 
      <artifactId>commons-dbcp</artifactId> 
      <version>1.4</version> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>5.2.1.Final</version> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>4.1.6.RELEASE</version> 
     </dependency> 


     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.12</version> 
      <scope>test</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/exec-maven-plugin --> 
     <dependency> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.2.1</version> 
     </dependency> 

    </dependencies> 

以下但我似乎越來越未發現異常

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.LocalSessionFactoryBean 

會有人能夠就爲哪些依賴我缺少的一類?

謝謝

回答

2

從4.2版本的spring-orm中添加了對hibernate 5的支持。您可以使用最新的4.3.2版本。

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>4.3.2.RELEASE</version> 
</dependency> 
相關問題