首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spring @autowired

spring @autowired
EN

Stack Overflow用户
提问于 2009-10-15 05:04:08
回答 2查看 4.9K关注 0票数 1

使用@autowired。在xml中,我只需要包括

<context:annotation-config />

我还需要贴什么标签吗?需要放componenet-scan吗?

奇怪,我在下面发现了错误

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-10-15 07:19:27

<context:annotation-config />选项是在Spring2.5中引入的。在幕后,这将创建和配置一个RequiredAnnotationBeanPostProcessor,并使用该属性的order属性。在Spring2.0中,RequiredAnnotationBeanPostProcessor存在,但没有order属性。

我猜您的类路径上同时有Spring2.5和2.0。2.5的副本允许您使用<context:annotation-config />,但随后它使用了RequiredAnnotationBeanPostProcessor的2.0副本。

票数 2
EN

Stack Overflow用户

发布于 2009-10-15 07:10:08

这看起来像是类路径问题。您是混合了不同Spring的不兼容版本,还是在类路径上有多个RequiredAnnotationBeanPostProcessor类?

该类的早期版本(最多2.0.x)没有order属性。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1570367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档