使用 hibernate、hibernate 注解和 ehcache 的 Maven 依赖项是什么?

发布于 2024-09-30 16:21:30 字数 6633 浏览 0 评论 0原文

我想使用最新的 hibernate、hibernate-annotations 和 ehcache 依赖项更新我的 Maven pom.xml。

我阅读了 hibernate 下载页面和 ehcache 下载页面。我所有解释它的尝试似乎都失败了。有人可以写出应该进入 pom.xml 的片段吗?

隐秘的休眠下载页面: http://hibernate.org/downloads

神秘的 ehcache 下载页面: http://www.terracotta.org/dl/ehcache-oss-download-这

是我到目前为止所拥有的:

   <properties>
       <hibernate.version>3.6.0.Final</hibernate.version>
   </properties>
   <dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
            <exclusion>
                <groupId>javax.transaction</groupId>
                <artifactId>jta</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
            <exclusion>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>2.2.0</version>
        <type>pom</type>
    </dependency>
 </dependencies>

    <repositories>
        <repository>
            <id>codehaus-repository</id>
            <name>Codehaus</name>
            <url>https://nexus.codehaus.org/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net</id>
            <url>http://download.java.net/maven/1</url>
            <layout>legacy</layout>
        </repository>
        <repository>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <layout>default</layout>
            <url>http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>sonatype-ehcache</id>
            <url>http://oss.sonatype.org/content/repositories/sourceforge-releases</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>JBoss Repository</id>
            <url>https://repository.jboss.org/nexus/content/groups/public</url>
            <layout>default</layout>
        </repository>
    </repositories>

我知道,它看起来像一团糟,因为我似乎不知道所有依赖项都存储在哪里。

以上失败并显示:

Invocation of init method failed; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)

更新: 帕斯卡,你的回复非常清楚并且解释得很好。但是,hibernate 启动时仍然失败。

  1. sl4j 抛出错误,通过添加以下内容即可消失:

    <依赖>;
        org.slf4j;
        slf4j-log4j12;
        <版本>1.6.1
    
    
  2. 此警告有很多实例:

    g 在两阶段提交中!
    1797 [主要] 警告 net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory - 没有 Tr
    在 Hibernate 配置中发现 ansactionManagerLookup,XA Caches 将参与
    
  3. 此外,此错误使一切都失败:

    相关原因:

    org.springframework.beans.factory.BeanCreationException:创建 bean 时出错
    ServletContext 资源中定义的 h 名称“financialDAO”[/WEB-INF/config/applic
    ationContext-database.xml]:无法解析对 bean 'transactionManager 的引用
    '同时设置bean属性'transactionManager';嵌套异常是 org.spri
    ngframework.beans.factory.BeanCreationException:创建名为 ' 的 bean 时出错
    transactionManager' 在 ServletContext 资源中定义 [/WEB-INF/config/applicat
    ionContext-database.xml]:无法解析对 bean 'sessionFactory' 的引用
    e 设置 bean 属性“sessionFactory”;嵌套异常是 org.springframewor
    k.beans.factory.BeanCreationException:创建名为“sessionFac”的 bean 时出错
    tory' 在 ServletContext 资源中定义 [/WEB-INF/config/applicationContext-dat
    abase.xml]:调用init方法失败;嵌套异常是 java.lang.Null
    指针异常
        在 org.springframework.beans.factory.support.BeanDefinitionValueResolver
    .resolveReference(BeanDefinitionValueResolver.java:328)
    

确认一下,这是 spring 配置:

<!-- Enable EHCache -->
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">/ehcache.xml</prop>

更新: 这似乎是 hibernate 遇到的最新异常:

Caused by: java.lang.NullPointerException
    at net.sf.ehcache.hibernate.HibernateUtil.loadAndCorrectConfiguration(HibernateUtil.java:48)
    at net.sf.ehcache.hibernate.EhCacheRegionFactory.start(EhCacheRegionFactory.java:79)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:236)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)

I would like to update my Maven pom.xml with the latest hibernate, hibernate-annotations, and ehcache dependencies.

I read the hibernate download page and the ehcache donwload page. All my tries at interpreting it seem to fail. Can someone write out the snippet that should go into pom.xml?

Cryptic hibernate download page:
http://hibernate.org/downloads

Cryptic ehcache download page:
http://www.terracotta.org/dl/ehcache-oss-download-catalog

Here is what I have so far:

   <properties>
       <hibernate.version>3.6.0.Final</hibernate.version>
   </properties>
   <dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
            <exclusion>
                <groupId>javax.transaction</groupId>
                <artifactId>jta</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
            <exclusion>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>2.2.0</version>
        <type>pom</type>
    </dependency>
 </dependencies>

    <repositories>
        <repository>
            <id>codehaus-repository</id>
            <name>Codehaus</name>
            <url>https://nexus.codehaus.org/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net</id>
            <url>http://download.java.net/maven/1</url>
            <layout>legacy</layout>
        </repository>
        <repository>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <layout>default</layout>
            <url>http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>sonatype-ehcache</id>
            <url>http://oss.sonatype.org/content/repositories/sourceforge-releases</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>JBoss Repository</id>
            <url>https://repository.jboss.org/nexus/content/groups/public</url>
            <layout>default</layout>
        </repository>
    </repositories>

I know, it looks like a big mess, because I don't seem to figure out, where all the dependencies are stored.

The above fails with:

Invocation of init method failed; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)

Update:
Pascal, your reply is very clear and well explained. However, hibernate still fails on startup.

  1. sl4j threw errors, which went away by adding:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
    </dependency>
    
  2. There are many instances of this warning:

    g in the two-phase commit!
    1797 [main] WARN  net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory  - No Tr
    ansactionManagerLookup found in Hibernate config, XA Caches will be participatin
    
  3. Additionally, this error makes everything fail:

    Related cause:

    org.springframework.beans.factory.BeanCreationException: Error creating bean wit
    h name 'financialDAO' defined in ServletContext resource [/WEB-INF/config/applic
    ationContext-database.xml]: Cannot resolve reference to bean 'transactionManager
    ' while setting bean property 'transactionManager'; nested exception is org.spri
    ngframework.beans.factory.BeanCreationException: Error creating bean with name '
    transactionManager' defined in ServletContext resource [/WEB-INF/config/applicat
    ionContext-database.xml]: Cannot resolve reference to bean 'sessionFactory' whil
    e setting bean property 'sessionFactory'; nested exception is org.springframewor
    k.beans.factory.BeanCreationException: Error creating bean with name 'sessionFac
    tory' defined in ServletContext resource [/WEB-INF/config/applicationContext-dat
    abase.xml]: Invocation of init method failed; nested exception is java.lang.Null
    PointerException
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
    .resolveReference(BeanDefinitionValueResolver.java:328)
    

To confirm, this is the spring configuration:

<!-- Enable EHCache -->
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">/ehcache.xml</prop>

Update:
This seems to be the latest exception that hibernate gets stuck on:

Caused by: java.lang.NullPointerException
    at net.sf.ehcache.hibernate.HibernateUtil.loadAndCorrectConfiguration(HibernateUtil.java:48)
    at net.sf.ehcache.hibernate.EhCacheRegionFactory.start(EhCacheRegionFactory.java:79)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:236)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏蝶舞 2024-10-07 16:21:30

如果您确实指的是 hibernate-annotations(而不是 hibernate-entitymanager)和 ehcache 的最终版本,那么您将需要以下内容:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.6.0.Final</version>
    </dependency>
    <dependency>
       <groupId>net.sf.ehcache</groupId>
       <artifactId>ehcache-core</artifactId>
       <version>2.2.0</version>
   </dependency>
   ...
  </dependencies>

  <repositories>
    <repository>
      <id>repository.jboss.org-public</id>
      <name>JBoss repository</name>
      <url>https://repository.jboss.org/nexus/content/groups/public</url>
    </repository>
  </repositories>
  ...
</project>

从 Hibernate 3.6 开始,JDK 1.4 支持已被删除,并且 Hibernate Annotations 已合并回 Core 。

我的意思是 Hibernate EntityManager,然后在上面的代码片段中将 hibernate-core 替换为 hibernate-entitymanager

关于 EHCache,ehcache-core 应该提供您需要的一切(包括“新”Hibernate 3.3/3.5 缓存 SPI 的实现) 及其 CacheRegionFactory)。因此,正如记录的

将 Ehcache 设置为 Hibernate 二级缓存

Hibernate 3.3 及更高版本

注意 HIBERNATE 3.2 用户

请务必记下属性名称和值的更改。

用途:

<属性名称=“hibernate.cache.region.factory_class”>
          net.sf.ehcache.hibernate.EhCacheRegionFactory

例如创建实例,或

<属性名称=“hibernate.cache.region.factory_class”>
          net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory

强制 Hibernate 使用单例
Ehcache CacheManager。


后续:回答您的更新:

sl4j 抛出错误,通过添加 (...) 即可消失

好吧,我无法猜测您正在使用什么日志框架,提供您选择的绑定作为读者的练习:)

此警告有很多实例(...)

在非 JTA 环境中运行时,我只收到一个 WARNING。如果这是您的情况(非 JTA 环境),我会认为 WARNING 是正常的。如果您不是这样,请查看有关 JTA 的文档。

此外,这个错误使一切都失败

这是一个不同的问题(但看起来 SessionFactory 无法正确初始化,激活日志记录以查看原因),我建议发布一个新的 spring 特定问题。

If you really mean the ultimate versions of hibernate-annotations (and not hibernate-entitymanager) and ehcache, then you'll need the following:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.6.0.Final</version>
    </dependency>
    <dependency>
       <groupId>net.sf.ehcache</groupId>
       <artifactId>ehcache-core</artifactId>
       <version>2.2.0</version>
   </dependency>
   ...
  </dependencies>

  <repositories>
    <repository>
      <id>repository.jboss.org-public</id>
      <name>JBoss repository</name>
      <url>https://repository.jboss.org/nexus/content/groups/public</url>
    </repository>
  </repositories>
  ...
</project>

As of Hibernate 3.6, JDK 1.4 support has been dropped and the Hibernate Annotations have been merged back into Core.

I you meant Hibernate EntityManager, then replace hibernate-core by hibernate-entitymanager in the above snippet.

Regarding EHCache, ehcache-core should provide everything you need (including implementations of the "new" Hibernate 3.3/3.5 caching SPI with its CacheRegionFactory). So, as documented:

Setting Ehcache as the Hibernate Second Level Cache

Hibernate 3.3 and higher

ATTENTION HIBERNATE 3.2 USERS

Make sure to note the change to BOTH the property name and value.

Use:

<property name="hibernate.cache.region.factory_class">
          net.sf.ehcache.hibernate.EhCacheRegionFactory</property>

for instance creation, or

<property name="hibernate.cache.region.factory_class">
          net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</property>

to force Hibernate to use a singleton
of Ehcache CacheManager.


Follow-up: To answer your update:

sl4j threw errors, which went away by adding (...)

Well, I can't guess what logging framework you're using, providing the binding of your choice was left as an exercise for the reader :)

There are many instances of this warning (...)

I get only one WARNING when running in a non JTA environment. If that's your case (a non JTA environment), I would consider the WARNING as normal. If that's not your case, have a look at the documentation about JTA.

Additionally, this error makes everything fail

This is somehow a different question (but it looks like the SessionFactory fails to initialize properly, activate logging to see why) and I suggest to post a new spring specific question.

百合的盛世恋 2024-10-07 16:21:30

如果您将 Spring 3 与 hibernate 3 集成,则可以通过此 pom.xml

<properties>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>

<dependencies>
    <!-- Core utilities used by other modules. Define this if you use Spring 
        Utility APIs (org.springframework.core.*/org.springframework.util.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Expression Language (depends on spring-core) Define this if you use 
        Spring Expression APIs (org.springframework.expression.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Bean Factory and JavaBeans utilities (depends on spring-core) Define 
        this if you use Spring Bean APIs (org.springframework.beans.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core, 
        spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Application Context (depends on spring-core, spring-expression, spring-aop, 
        spring-beans) This is the central artifact for Spring's Dependency Injection 
        Container and is generally always defined -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Various Application Context utilities, including EhCache, JavaMail, 
        Quartz, and Freemarker integration Define this if you need any of these integrations -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Transaction Management Abstraction (depends on spring-core, spring-beans, 
        spring-aop, spring-context) Define this if you use Spring Transactions or 
        DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, 
        spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, 
        and iBatis. (depends on spring-core, spring-beans, spring-context, spring-tx) 
        Define this if you need ORM (org.springframework.orm.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, 
        JiBX, Castor, XStream, and XML Beans. (depends on spring-core, spring-beans, 
        spring-context) Define this if you need OXM (org.springframework.oxm.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Web application development utilities applicable to both Servlet and 
        Portlet Environments (depends on spring-core, spring-beans, spring-context) 
        Define this if you use Spring MVC, or wish to use Struts, JSF, or another 
        web framework with Spring (org.springframework.web.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Spring MVC for Servlet Environments (depends on spring-core, spring-beans, 
        spring-context, spring-web) Define this if you use Spring MVC with a Servlet 
        Container such as Apache Tomcat (org.springframework.web.servlet.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Spring MVC for Portlet Environments (depends on spring-core, spring-beans, 
        spring-context, spring-web) Define this if you use Spring MVC with a Portlet 
        Container (org.springframework.web.portlet.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc-portlet</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Support for testing Spring applications with tools such as JUnit and 
        TestNG This artifact is generally always defined with a 'test' scope for 
        the integration testing framework and unit testing stubs -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework.version}</version>
        <scope>test</scope>
    </dependency>


    <!-- Hibernate resources -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.7.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.3.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.3.0.ga</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.3.1.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
    </dependency>
    <!-- EhCache -->
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>


    <!-- Taglibs -->

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>20030825.184428</version>
    </dependency>
    <dependency>
        <groupId>commons-pool</groupId>
        <artifactId>commons-pool</artifactId>
        <version>20030825.183949</version>
    </dependency>

    <!-- Log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <type>jar</type>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.6</version>
    </dependency>


    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

如果您想要不同版本的 hibernate,您可以检查 这里

You can go by this pom.xml if you are integrating Spring 3 with hibernate 3

<properties>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>

<dependencies>
    <!-- Core utilities used by other modules. Define this if you use Spring 
        Utility APIs (org.springframework.core.*/org.springframework.util.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Expression Language (depends on spring-core) Define this if you use 
        Spring Expression APIs (org.springframework.expression.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Bean Factory and JavaBeans utilities (depends on spring-core) Define 
        this if you use Spring Bean APIs (org.springframework.beans.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core, 
        spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Application Context (depends on spring-core, spring-expression, spring-aop, 
        spring-beans) This is the central artifact for Spring's Dependency Injection 
        Container and is generally always defined -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Various Application Context utilities, including EhCache, JavaMail, 
        Quartz, and Freemarker integration Define this if you need any of these integrations -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Transaction Management Abstraction (depends on spring-core, spring-beans, 
        spring-aop, spring-context) Define this if you use Spring Transactions or 
        DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, 
        spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, 
        and iBatis. (depends on spring-core, spring-beans, spring-context, spring-tx) 
        Define this if you need ORM (org.springframework.orm.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, 
        JiBX, Castor, XStream, and XML Beans. (depends on spring-core, spring-beans, 
        spring-context) Define this if you need OXM (org.springframework.oxm.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Web application development utilities applicable to both Servlet and 
        Portlet Environments (depends on spring-core, spring-beans, spring-context) 
        Define this if you use Spring MVC, or wish to use Struts, JSF, or another 
        web framework with Spring (org.springframework.web.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Spring MVC for Servlet Environments (depends on spring-core, spring-beans, 
        spring-context, spring-web) Define this if you use Spring MVC with a Servlet 
        Container such as Apache Tomcat (org.springframework.web.servlet.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Spring MVC for Portlet Environments (depends on spring-core, spring-beans, 
        spring-context, spring-web) Define this if you use Spring MVC with a Portlet 
        Container (org.springframework.web.portlet.*) -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc-portlet</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <!-- Support for testing Spring applications with tools such as JUnit and 
        TestNG This artifact is generally always defined with a 'test' scope for 
        the integration testing framework and unit testing stubs -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework.version}</version>
        <scope>test</scope>
    </dependency>


    <!-- Hibernate resources -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.7.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.3.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.3.0.ga</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.3.1.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
    </dependency>
    <!-- EhCache -->
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>


    <!-- Taglibs -->

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>20030825.184428</version>
    </dependency>
    <dependency>
        <groupId>commons-pool</groupId>
        <artifactId>commons-pool</artifactId>
        <version>20030825.183949</version>
    </dependency>

    <!-- Log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <type>jar</type>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.6</version>
    </dependency>


    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

And if you want different versions of hibernate you can check here

听,心雨的声音 2024-10-07 16:21:30
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>5.2.2.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>5.2.2.Final</version>
</dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文