我已在群集中安装并运行JBoss 7。我正在开发一个Spring Boot 1.3.2应用程序。我在domain.xml中定义了以下Infinispan缓存:
<cache-container name="my-cache" default-cache="auth">
<transport stack="tcp" lock-timeout="10000"/>
<replicated-cache name="auth" mode="SYNC" batching="true">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="NONE"/>
<eviction strategy="LRU" max-entries="100"/>
<expiration max-idle="300000"/>
</replicated-cache>
</cache-container>
在application.properties文件中,我定义了以下内容:
spring.cache.type=infinispan
然后在我定义的缓存类中:
@CacheConfig(cacheNames="java:jboss/infinispan/cache/my-cache/auth")
当我尝试在JBoss上部署应用程序时,我收到以下错误:
Caused by: java.lang.IllegalArgumentException: No cache manager could be auto-configured, check your configuration (caching type is 'INFINISPAN'
如何配置它才能正常工作?
答案 0 :(得分:4)
好的,我按照this教程解决了问题。
这就是我所做的。
我创建了缓存配置类,它将定义我在JBoss中配置的CacheManager:
@Configuration
@EnableCaching
public class CachingConfig {
@Bean
public CacheManager cacheManager() {
JndiTemplate jndiTemplate = new JndiTemplate();
try {
EmbeddedCacheManager embededCacheManager = (EmbeddedCacheManager) jndiTemplate.lookup("java:jboss/infinispan/container/my-cache");
SpringEmbeddedCacheManager cacheManager = new SpringEmbeddedCacheManager(embededCacheManager);
return cacheManager;
} catch (NamingException e) {
e.printStackTrace();
return null;
}
}
}
我添加了以下依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-spring</artifactId>
<version>5.1.2.FINAL</version>
</dependency>
明确宣布Infinispan依赖:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>org.infinispan</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>