org.springframework.web.context.ContextLoader:307项目编译后无法启动总是报错

org.springframework.web.context.ContextLoader:307 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'computationService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ekyb.common.arithmetic.service.ArithmeticService com.ekyb.common.arithmetic.service.impl.ComputationServiceImpl.arithmeticService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arithmeticServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.sf.ehcache.Cache com.ekyb.common.arithmetic.service.impl.ArithmeticServiceImpl.cache; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [net.sf.ehcache.Cache] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)

百度了半天都说是自家项目spring3.1.0和jdk1.8版本不对付,但是换成jdk1.7之后仍然报错,继续整理

整理发现自家项目本地的mq不起也会报这个错,因为在mac系统安装和启动mq后仍报错,以为是项目连接不到mq地址,在项目中ping tcp地址没有问题。

最后研究项目自身问题发现computationService下Cache注入上

@org.springframework.beans.factory.annotation.Autowired(required=true)

true改成false

在编译项目启动没有问题了,

但是此项为true时在Windows系统下可以正常启动,在mac环境下却不可以。

 


版权声明:本文为u012588620原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。