spring-hibernate3 with hibernate-core-4.1.2

时间:2012-04-28 17:36:51

标签: java spring hibernate maven

我想在Spring控制的视图模式中设置开放会话。我正在使用Hibernate 4.1.2。现在如果我在pom.xml中添加spring-hibernate3,最后会添加它的依赖hibernate-3.2.5.ga。我想我不能同时拥有这两个冬眠。

如果我想使用spring-hibernate3,我应该删除hibernate-core-4.1.2.jar吗?

这是我的pom:

<dependencies>
    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-core</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-spring</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-extensions</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-datetime</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.jqwicket</groupId>
        <artifactId>jqwicket</artifactId>
        <version>0.8</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.2</version>
    </dependency>
    <dependency>
        <groupId>hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>1.8.0.10</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.2.2</version>
    </dependency>       
    <dependency> 
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>   
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.4.2</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
    </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:2)

是的,如果从pom.xml文件中删除hibernate-core 4.1.2依赖项,那么你的类路径中只会有hibernate3 jar。

但是,因为spring-hibernate看起来很旧(从Spring的角度来看,最新的是2.0.8 version,最新的Spring Core是3.1.1)

但我认为你可以使用当前设置的视图模式中的open会话,因为spring-orm-3.1.1支持Hibernate4;看看http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/orm/hibernate4/support/package-summary.html