Article From:https://segmentfault.com/q/1010000011712303
Question:

The error message is as follows
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.cache.annotation.AnnotationCacheOperationSource#0’: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.cache.config.internalCacheAdvisor’: Cannot resolve reference to bean ‘org.springframework.cache.annotation.AnnotationCacheOperationSource#0’ while setting bean property ‘cacheOperationSource’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.cache.config.internalJCacheAdvisor’: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/cache/annotation/CacheRemove

Configuration information is as follows

<cache:annotation-driven/>
    <context:component-scan base-package="com.smart.cache.ehcache"/>

    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
          p:cacheManager-ref="ehcache"/>

    <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
          p:configLocation="classpath:ehcache.xml"/>

ehcacche.xml

<ehcache>
    <cache name="users"
           maxElementsInMemory="1000" />
</ehcache>

Answer 0:
<dependency>
    <groupId>javax.cache</groupId>
    <artifactId>cache-api</artifactId>
</dependency>

Answer 1:

Replace Maven dependency:

<dependency>
    <groupId>com.googlecode.ehcache-spring-annotations</groupId>
    <artifactId>ehcache-spring-annotations</artifactId>
    <version>1.1.2</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core</artifactId>
    <version>2.1.0</version>
</dependency>

Maybe there is a problem with the version of the package.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *