HIbernate 的 ehCache 和 Spring MVC 错误

发布于 2024-10-26 21:26:44 字数 1982 浏览 1 评论 0原文

在 Spring MVC 中设置 ehcache 时,我不断收到此错误。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheEvictionTask': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.CacheManager.getName()Ljava/lang/String;

下面是我的设置,我使用 hibernate 3.2.7.GA

<ehcache:config cache-manager="ehCacheManager">
    <ehcache:evict-expired-elements interval="60" />
</ehcache:config>

<beans:bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <beans:property name="configLocation"  value="/WEB-INF/spring/ehcache.xml"/>
</beans:bean>

Pom.xml

<dependency>
          <groupId>com.googlecode.ehcache-spring-annotations</groupId>
          <artifactId>ehcache-spring-annotations</artifactId>
          <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache-core</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
           <groupId>net.sf.ehcache</groupId>
           <artifactId>ehcache</artifactId>
           <version>2.3.2</version>
           <type>pom</type>
       </dependency>
    </dependencies>
    <repositories>
          <repository>
            <id>terracotta-releases</id>
            <url>http://www.terracotta.org/download/reflector/releases</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

I keep getting this error while setting up ehcache in Spring MVC.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheEvictionTask': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.CacheManager.getName()Ljava/lang/String;

Below is my setup, and I am using hibernate 3.2.7.GA

<ehcache:config cache-manager="ehCacheManager">
    <ehcache:evict-expired-elements interval="60" />
</ehcache:config>

<beans:bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <beans:property name="configLocation"  value="/WEB-INF/spring/ehcache.xml"/>
</beans:bean>

Pom.xml

<dependency>
          <groupId>com.googlecode.ehcache-spring-annotations</groupId>
          <artifactId>ehcache-spring-annotations</artifactId>
          <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache-core</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
           <groupId>net.sf.ehcache</groupId>
           <artifactId>ehcache</artifactId>
           <version>2.3.2</version>
           <type>pom</type>
       </dependency>
    </dependencies>
    <repositories>
          <repository>
            <id>terracotta-releases</id>
            <url>http://www.terracotta.org/download/reflector/releases</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

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

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

发布评论

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

评论(2

凉世弥音 2024-11-02 21:26:44

在项目网站上下载的包含依赖项的 ehcache-spring-annotations zip 文件包含 ehcache-core 版本 2.2.0。您正在使用 2.3.2。这些版本之间可能不兼容。

The zip file of ehcache-spring-annotations containing the dependencies, downloaded on the project web site, contains ehcache-core version 2.2.0. You're using 2.3.2. There might be an incompatibility between those versions.

话少心凉 2024-11-02 21:26:44

通过使用排除使其工作,所以是的,存在冲突问题。

   <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-commons-annotations</artifactId>
                <version>${org.hibernate.commons.annotations-version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>net.sf.ehcache</groupId>
                        <artifactId>ehcache</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

Got it working by using an exclude, so yes there was a clash issue.

   <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-commons-annotations</artifactId>
                <version>${org.hibernate.commons.annotations-version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>net.sf.ehcache</groupId>
                        <artifactId>ehcache</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文