[英]Spring Boot and Infinspan cache on JBoss
I have JBoss 7 installed and running in a cluster. 我已经在集群中安装并运行了JBoss 7。 I'm developing a Spring Boot 1.3.2 application. 我正在开发一个Spring Boot 1.3.2应用程序。 I defined a following Infinispan cache in domain.xml: 我在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>
In application.properties file I defined a following: 在application.properties文件中,我定义了以下内容:
spring.cache.type=infinispan
And then on my cache class I defined: 然后在我的缓存类中定义:
@CacheConfig(cacheNames="java:jboss/infinispan/cache/my-cache/auth")
When I try to deploy the app on JBoss I get the following error: 当我尝试在JBoss上部署应用程序时,出现以下错误:
Caused by: java.lang.IllegalArgumentException: No cache manager could be auto-configured, check your configuration (caching type is 'INFINISPAN'
How can I configure it to work properly? 如何配置它才能正常工作?
OK, I followed this tutorial and solved the issue. 好的,我按照本教程解决了该问题。
This is what I did. 这就是我所做的。
I created cache config class which will define my CacheManager configured in JBoss: 我创建了缓存配置类,它将定义在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;
}
}
}
I added following dependencies: 我添加了以下依赖项:
<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>
And explicitly declared Infinispan 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.