高分求解Spring配置问题,在线等解答!

kosora曹 2013-07-22 03:27:50
公司的项目需要重构---把原来的XML里边的bean配置全都换成注入注解,现在报以下错误:
(MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iataSectionService' defined in "/D:/cmrm/CMRM/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/standalone/deployments/cmrm-web.war/WEB-INF/lib/cmrm-master-1.0.0-SNAPSHOT.jar/applicationContext-master.xml":
Cannot resolve reference to bean 'countryService' while setting bean property 'countryService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'countryService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.acca.cmrm.master.app.service.RegionService cn.com.acca.cmrm.master.app.service.impl.CountryServiceImpl.regionService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'regionService' defined in "/D:/cmrm/CMRM/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/standalone/deployments/cmrm-web.war/WEB-INF/lib/cmrm-master-1.0.0-SNAPSHOT.jar/applicationContext-master.xml": Cannot resolve reference to bean 'provinceService' while setting bean property 'provinceService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provinceService' defined in "/D:/cmrm/CMRM/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/standalone/deployments/cmrm-web.war/WEB-INF/lib/cmrm-master-1.0.0-SNAPSHOT.jar/applicationContext-master.xml": Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'countryService' of bean class [cn.com.acca.cmrm.master.app.service.impl.ProvinceServiceImpl]: Bean property 'countryService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
关于CountryServiceImpl和RegionServiceImpl,出现了循环引用:

@Service("countryService")
public class CountryServiceImpl extends BaseService<Country> implements CountryService {
@Autowired
private RegionService regionService;
@Autowired
private AreaService areaService;

/**
* @param regionService the regionService to set
*/
public void setRegionService(RegionService regionService) {
this.regionService = regionService;
}

/**
* @param areaService the areaService to set
*/
public void setAreaService(AreaService areaService) {
this.areaService = areaService;
}



@Service("regionService")
public class RegionServiceImpl extends BaseService<Region> implements RegionService {
@Autowired
private CountryService countryService;

/**
* @param countryService the countryService to set
*/
public void setCountryService(CountryService countryService) {
this.countryService = countryService;
}

是循环引用的问题?还是其他问题?欢迎高手解答!
...全文
165 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
litongde_java 2013-07-23
  • 打赏
  • 举报
回复
小丑哥_V5 2013-07-23
  • 打赏
  • 举报
回复
kosora曹 2013-07-22
  • 打赏
  • 举报
回复
明天回公司再给大家贴代码!
桃园闲人 2013-07-22
  • 打赏
  • 举报
回复
iataSectionService这个bean中countryService属性是如何注入的,贴代码。。。。
oh_Maxy 2013-07-22
  • 打赏
  • 举报
回复
AreaService 的源码呢?这里加注解没。 另外,注意可能同类,但是路径不一样的情况,要注意import的类路径
Fate- 2013-07-22
  • 打赏
  • 举报
回复
Cannot resolve reference to bean 'countryService' while setting bean property 'countryService'; 注入有问题嘛 好好看看
七神之光 2013-07-22
  • 打赏
  • 举报
回复
Cannot resolve reference to bean 'countryService' while setting bean property 'countryService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'countryService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.acca.cmrm.master.app.service.RegionService cn.com.acca.cmrm.master.app.service.impl.CountryServiceImpl.regionService
查查这个iataSectionService 里面的
  • 打赏
  • 举报
回复
provinceService这个bean看看

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧