0
我试图使用多个ehcahe.xml配置文件来代替将使用定义的缓存的模块。多引导项目中的Spring Boot ehcache
何时将ehcache.xml配置置于启动spring引导应用程序的app-web模块的资源下,它适用于@EnableCaching
。
@SpringBootApplication
@Import({ CommonApp.class, CoreConfig.class})
@EnableSwagger2
@EnableCaching
public class WebApplication extends WeblogicMvcConfigurerAdapter {
}
但是,当是该应用核心模块下放置并@EnableCaching
被CoreConfig
其通过WebApplication
它上运行时失败进口下方移动的配置。
@Configuration
@ComponentScan
@EnableCaching
public class CoreConfig {
}
当@Cacheable
方法被调用我得到
java.lang.IllegalArgumentException: Cannot find cache named 'systemParameterCache'
我的想法是,每个模块可以有属于该模块的高速缓存自己ehcache.xml中配置。
可以这样使用吗?我做错了什么?
谢谢!
我的意图是在Common中定义一个CacheManager,并通过多个模块共享它(使用'shared'为[EhCacheManagerFactoryBean](https://docs.spring.io/spring/docs/current/javadoc- api/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.html#setShared-boolean-)),并使用此CacheManager实例在自定义缓存提供程序中配置适当的模块和缓存,使用此模块使用的'ehcache.xml'配置。 我只是好奇,如果Spring Boot默认提供类似的东西。 无论如何感谢您的回答! – Kuciin