无法在春天自动装配

时间:2013-11-01 10:43:41

标签: java spring annotations autowired

我现在已经在这里提出了这个问题,但我真的尝试过讨论,但没有一个对我有用。

基本上我得到“前缀”上下文“for element”上下文:annotation-config“未绑定”错误,我使用@Autowired排除在bean xml中使用property元素。

这是我的xml文件的标签

xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd">

我也有

<context:annotation-config/>  

自动注册AutowiredAnnotationBeanProcessor

问题可能来自类路径中缺少的jar,无法在命名空间和spring jar之间进行maping吗?这是外部罐子

org.springframework.aop-3.1.0.M2

org.springframework.asm-3.1.0.M2

org.springframework.beans-3.1.0.M2

org.springframework.context.support-3.1.0.M2

org.springframework.context-3.1.0.M2

org.springframework.core-3.1.0.M2

org.springframework.expression-3.1.0.M2

弹簧上下文3.0.6

弹簧豆-3.0.6

共享记录-1.1.1

1 个答案:

答案 0 :(得分:1)

您缺少的是名称空间前缀声明:

<beans xmlns:context="http://www.springframework.org/schema/context">