[英]spring @autowired
to use @autowired. 使用@autowired。 in xml, i only need to included
在xml中,我只需要包含
<context:annotation-config />
? <context:annotation-config />
吗?
is there any other tag i need to put ? 我还需要贴其他标签吗? need to put componenet-scan ?
需要放置componenet-scan吗?
weird, i get error below 很奇怪,我在下面看到错误
ERROR - ContextLoader.initWebApplicationContext(203) | Context initialization fa
iled
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'org.springframework.context.annotation.internalRequiredAnnotationProcess
or': Initialization of bean failed; nested exception is org.springframework.bean
s.InvalidPropertyException: Invalid property 'order' of bean class [org.springfr
amework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor]: No proper
ty 'order' found
Caused by:
org.springframework.beans.InvalidPropertyException: Invalid property 'order' of
bean class [org.springframework.beans.factory.annotation.RequiredAnnotationBeanP
ostProcessor]: No property 'order' found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrap
perImpl.java:376)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
The <context:annotation-config />
option was introduced in Spring 2.5. <context:annotation-config />
选项是在Spring 2.5中引入的。 Under the covers, this creates and configures a RequiredAnnotationBeanPostProcessor
, and uses the order
property of that. 在幕后,这将创建并配置
RequiredAnnotationBeanPostProcessor
,并使用该属性的order
属性。 In Spring 2.0, RequiredAnnotationBeanPostProcessor
exists, but has no order
property. 在Spring 2.0中,
RequiredAnnotationBeanPostProcessor
存在,但是没有order
属性。
My guess is that you have both Spring 2.5 and 2.0 on your classpath. 我的猜测是您的类路径上同时具有Spring 2.5和2.0。 The copy of 2.5 would have allowed you to use
<context:annotation-config />
, but then it used the 2.0 copy for RequiredAnnotationBeanPostProcessor
. 2.5的副本将允许您使用
<context:annotation-config />
,但是随后它将2.0的副本用于RequiredAnnotationBeanPostProcessor
。
This looks like a class path issue. 这看起来像一个类路径问题。 Do you mix incompatible versions of different Spring jars, or are there multiple
RequiredAnnotationBeanPostProcessor
classes on your classpath? 您是否混合使用不同版本的Spring jar的不兼容版本,或者您的类路径上是否存在多个
RequiredAnnotationBeanPostProcessor
类?
Earlier versions of that class (up to 2.0.x) did not have an order property. 该类的早期版本(最高2.0.x)没有order属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.