Reputation: 35719
to use @autowired. in xml, i only need to included
<context:annotation-config />
?
is there any other tag i need to put ? need to put 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
Upvotes: 1
Views: 4944
Reputation: 403581
The <context:annotation-config />
option was introduced in Spring 2.5. Under the covers, this creates and configures a RequiredAnnotationBeanPostProcessor
, and uses the order
property of that. In Spring 2.0, RequiredAnnotationBeanPostProcessor
exists, but has no order
property.
My guess is that you have both Spring 2.5 and 2.0 on your classpath. The copy of 2.5 would have allowed you to use <context:annotation-config />
, but then it used the 2.0 copy for RequiredAnnotationBeanPostProcessor
.
Upvotes: 2
Reputation: 16339
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?
Earlier versions of that class (up to 2.0.x) did not have an order property.
Upvotes: 1