Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
多maven项目中的Spring Boot ehcache_Maven_Spring Boot_Ehcache - Fatal编程技术网

多maven项目中的Spring Boot ehcache

多maven项目中的Spring Boot ehcache,maven,spring-boot,ehcache,Maven,Spring Boot,Ehcache,我正在尝试使用多个ehcahe.xml配置文件来代替将使用已定义缓存的模块 何时将ehcache.xml配置放在启动spring boot应用程序的app web模块的资源下,它可以与@EnableCaching一起正常工作 @SpringBootApplication @Import({ CommonApp.class, CoreConfig.class}) @EnableSwagger2 @EnableCaching public class WebApplication extends W

我正在尝试使用多个ehcahe.xml配置文件来代替将使用已定义缓存的模块

何时将ehcache.xml配置放在启动spring boot应用程序的app web模块的资源下,它可以与
@EnableCaching
一起正常工作

@SpringBootApplication
@Import({ CommonApp.class, CoreConfig.class})
@EnableSwagger2
@EnableCaching
public class WebApplication extends WeblogicMvcConfigurerAdapter {
}
但是,当配置放置在app core模块下,并且
@EnableCaching
移动到
CoreConfig
下时,
WebApplication
会在运行时失败

@Configuration
@ComponentScan
@EnableCaching
public class CoreConfig {

}
当调用
@Cacheable
方法时,我得到

java.lang.IllegalArgumentException: Cannot find cache named 'systemParameterCache'
我的想法是,每个模块都可以有自己的ehcache.xml配置,其中包含属于该模块的缓存

可以这样使用吗?我做错了什么


谢谢

这是可能的。但我不建议这样做。一个应用程序中有一个缓存管理器就足够了。拥有很多资源是徒劳的。如果您在为缓存指定不同的名称时遇到困难,我建议您使用模块前缀

那么,我不知道你所说的模块是什么意思
@EnableCaching
应在应用程序中指定一次


但是如果只在
CoreConfig
上指定它,它应该可以工作。但是,您仍然需要在缓存配置中创建
systemParameterCache
。这似乎是你的问题

我的意图是在
common
中只定义一个CacheManager,并通过多个模块(使用
shared
for)共享它,然后在自定义缓存提供程序中使用此CacheManager实例,并使用此模块中使用的
ehcache.xml
配置来配置相应的模块和缓存。我只是好奇SpringBoot是否默认提供了类似的功能。无论如何,谢谢你的回答!