应用环境:使用了struts2、spring2.5和ibatis等。
问题重现:xml配置文件如下,
<bean id="logAction" class="packageName.LogAction" scope="prototype">
<property name="logManager" ref="logManager"/>
</bean>
<bean id="logManager" class="packageName.LogManagerImpl" scope="prototype">
<property name="logDao" ref="logDao"/>
</bean>
<bean id="logDao" class="packageName.LogDaoiBatis" scope="prototype">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
由于整个项目中有很多spring配置文件,这里的logManager 在别的地方也有配置,且指定的另外的一个类,在应用启动的时候,还没有报错(我想spring 只是检查,没有真正注入吧,还是有相关配置?),在用到该模块的时候,会报如下错误(大概意思是logAction无法为logManager这个属性注入bean):
Unable to instantiate Action, logAction, defined for 'queryLogs' in namespace 'ExampleNamespace'Error creating bean with name 'logAction' defined in ServletContext resource beanA.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy6] to required type [packageName.log.LogManager] for property 'logManager'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy6] to required type [packageName.log.LogManager] for property 'logManager': no matching editors or conversion strategy found - action - file:/F:/path/strutsConf.xml:9:71
ps:有些命名空间和文件名做了修改。strutsConf.xml某个模块的struts配置文件。
用下面配置方式就解决了重名的问题:
<bean id="logAction" class="packageName.LogAction" scope="prototype">
<property name="logManager">
<bean class="packageName.log.LogManagerImpl">
<property name="logDao">
<bean class="packageName.log.LogDaoiBatis" scope="prototype">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
</property>
</bean>
</property>
</bean>
只做个记录,研究的比较浅,有了解的请指教,呵呵 O(∩_∩)O~
分享到:
相关推荐
spring bean配置 运行环境:eclipse 构建工具:maven 不提供maven构建,maven用来解决jar包的依赖
spring xml配置的12個技巧 spring xml配置的12個技巧 spring xml配置的12個技巧
服务Spring利用依赖注入机制来简化工作同时提高易测性Springbeans及依赖以及beans类所需服务都在配置 文件中进行了详细介绍说明这个配置文件是典型XML格式但是它既冗长又不实用对于需要定义大量 Springbeans大工程来...
NULL 博文链接:https://pczhuce-126-com.iteye.com/blog/1315170
模拟spring的xml配置文件注入对象,里面用saxbuilder来解析xml文件。
主要介绍了详解Spring中bean的几种注入方式,主要介绍了4种注入,主要有属性注入、构造函数注入、工厂方法注入,非常具有实用价值,需要的朋友可以参考下
spring 重新动态加载数据库或xml中的bean,可以不用重启tomcat
这是在网上下载的例子,平时我们用的ioc都是在web中,本例实现在java application中实现依赖注入
通过@Bean 和spring的factoryBean注入的bean. 以及对应@service注解注入的类 通过@Autowired 注入对象的时间是现根据类型在根据beanName获取的案例集合
bean加入spring容器管理的方式,bean加入applicationcontext容器的方式
大家都知道spring有多重配置方式,基于XML,基于注解,基于java类的配置,其中基于XML是最强大的一种,下面这篇文章主要给大家介绍了关于Spring装配Bean之XML安装配置bean的相关资料,需要的朋友可以参考借鉴,下面...
本篇文章主要介绍了Spring中使用xml配置bean的细节,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
用于日志配置
spring基于xml配置加载bean 的demo 了解spring的反射机制
实现了XML注入Bean,为bean注入bean,构造注入,Map,List,Set,Property 注入
Spring框架xml注解配置方式实例,包括Maven配置文件pom.xml、Springxml配置文件ApplicationContext-1.xml,以及类源码
主要介绍了spring基于xml文件配置Bean过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
spring注入配置文件,使用注解注入的
Spring基于XML方式配置事务
本篇文章主要介绍了Spring boot将配置属性注入到bean类中,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧