在web.xml中定义了一个初始化资源的listener,这个listener需要从数据库中加载系统配置表,因此有了一下代码
<listener>
<listener-class>
cn.com.fensbook.base.system.source.InitSystemParamListener
</listener-class>
</listener>
public class InitSystemParamListener implements ServletContextListener {
private static Log LOG = LogFactory.getLog(InitSystemParamListener.class);
public void contextDestroyed(ServletContextEvent arg0) {}
public void contextInitialized(ServletContextEvent arg0) {
setParams(arg0);
}
/**
* 取得所有配置项
* @return
*/
private List<SystemParam> getParams(ServletContextEvent servletContext){
ApplicationContext context =new FileSystemXmlApplicationContext("classpath:spring-base.xml");
ISystemParamService systemParamService = (ISystemParamService) context.getBean("systemParamService");
return systemParamService.getAllParam();
}
private void setParams(ServletContextEvent servletContext){
List<SystemParam> params = getParams(servletContext);
for(SystemParam param : params){
LOG.info(param.getParamName()+"==============="+param.getParamValue());
servletContext.getServletContext().setAttribute(param.getParamName(), param.getParamValue());
}
}
}
到此处代码运行一切正常,但是我访问我的Action时,action通过
@Autowired
@Qualifier("userInfoService")
private IUserInfoService userInfoService;
注入service时,却报了如下错误
Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
Error creating bean with name “”sessionFactory”” defined in URL [file:/E:/codingTool/apache-tomcat-6.0.39/webapps/fensbook/WEB-INF/classes/spring-base.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
Error creating bean with name “”userInfoDao””: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”sessionFactory”” defined in URL [file:/E:/codingTool/apache-tomcat-6.0.39/webapps/fensbook/WEB-INF/classes/spring-base.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
Could not autowire field: private cn.com.fensbook.userinfo.dao.IUserInfoDAO cn.com.fensbook.userinfo.service.impl.UserInfoServiceImpl.userInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”userInfoDao””: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”sessionFactory”” defined in URL [file:/E:/codingTool/apache-tomcat-6.0.39/webapps/fensbook/WEB-INF/classes/spring-base.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
Error creating bean with name “”userInfoService””: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.fensbook.userinfo.dao.IUserInfoDAO cn.com.fensbook.userinfo.service.impl.UserInfoServiceImpl.userInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”userInfoDao””: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”sessionFactory”” defined in URL [file:/E:/codingTool/apache-tomcat-6.0.39/webapps/fensbook/WEB-INF/classes/spring-base.xml]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name. The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
哪位大神可以解决这个问题,跪谢