目录
问题一:Initial cause was null:30: Element does not allow nested elements.
shiro + ehcache
问题一:Initial cause was null:30: Element <ehcache> does not allow nested <ehcache> elements.
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shiroFilterFactoryBean' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'shiroFilterFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodInvokingFactoryBean' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'methodInvokingFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityManager' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'securityManager' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'cacheManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehcache' defined in class path resource [com/yang/config/cache/EhCacheConfig.class]: Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:30: Element <ehcache> does not allow nested <ehcache> elements.
解决方式:
说的是 <ehcache> 标签中 不允许存在 <ehcache> 标签,即不能出现标签套标签的情况
找到 ehcache.xml 文件 <ehcache> 标签 将里面的标签进行修改为 <cache>
问题二: Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodInvokingFactoryBean' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'methodInvokingFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shiroFilterFactoryBean' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'shiroFilterFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityManager' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'securityManager' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource [com/yang/config/shiro/ShiroConfig.class]: Unsatisfied dependency expressed through method 'cacheManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehcache' defined in class path resource [com/yang/config/cache/EhCacheConfig.class]: 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 ]
解决方式:
1.可以将 ehcache 版本修改为 2.5版本以下,
2.我再项目运行的时候,好像直接进行重启造成的,我先将项目停止让后再次启动没有出现这种问题(但是后面在问题重新的时候,无法重现。无语.........)