Spring命名策略

时间:2014-07-09 16:59:12

标签: java spring spring-mvc

我正在尝试在tomcat中部署我的Spring项目,但我遇到了这个问题:

> Información: Initializing Spring root WebApplicationContext 2014-07-09
> 18:51:24,838 [localhost-startStop-1] ERROR
> org.springframework.web.context.ContextLoader  - Context
> initialization failed
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'loginController': Injection of autowired
> dependencies failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Could not
> autowire field: security.LoginService
> security.LoginController.service; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'loginService' defined in ServletContext
> resource [/WEB-INF/config/security.xml]: Initialization of bean
> failed; nested exception is **java.lang.NoClassDefFoundError:
> org/springframework/cglib/core/SpringNamingPolicy**   at
> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
>   at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120)
>   at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
>   at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
>   at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
>   at ....

1 个答案:

答案 0 :(得分:1)

未来考古学家的注意事项:在尝试添加“全球方法安全”时,我注意到了类似的问题。使用旧的Spring 3.2.6 进行Web应用程序。

根本原因:缺少类org.springframework.cglib.core.SpringNamingPolicy

解决方案:将Spring更新为至少 3.2.8 (准确地说是弹簧核心)

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.2.8.RELEASE</version>
</dependency>