公司的项目需要重构---把原来的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;
}
是循环引用的问题?还是其他问题?欢迎高手解答!SpringBean异常Java注入注解
(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;
}
是循环引用的问题?还是其他问题?欢迎高手解答!SpringBean异常Java注入注解
解决方案 »
- ModelAndView能不能控制窗口大小
- org.hibernate.PropertyNotFoundException: Could not find a setter for property id in class
- 怎样配置path和classpath,在线等,跪求
- 数据展现问题
- 启动weblogic时报错
- 关于AOP装备(Advice)的问题
- 请问如何实现动态表单+validate框架的验证?
- jsp标签 在tomcat运行时提示Unable to load class mypackage.tt错误
- J2EE开发的OA中,邮件服务器一般怎么解决?急!!!!
- javabean 在 Tomcat 5.0 里的热拔插问题
- SSH遇到的一个问题,求帮解决
- s2sh环境下使用注解开发的教学视频
接口/*
* Copyright (c) 2012-2032 Accounting Center of China Aviation(ACCA).
* All Rights Reserved.
*/
package cn.com.acca.cmrm.master.app.service;import cn.com.acca.ajaf.core.exception.BusinessException;
import cn.com.acca.ajaf.core.service.IBaseService;
import cn.com.acca.cmrm.master.app.entity.Province;/**
* 省份Service接口层.
*
* @version cmrm-web v1.0
* @author Wu Yang, 2013-5-27
*/
public interface ProvinceService extends IBaseService<Province> { /**
* 判断省份代码是否存在,存在为true,不存在为false.
* @param provinceCode 省份代码.
* @return true or false.
* @throws BusinessException BusinessException.
*/
boolean isExisted(String provinceCode) throws BusinessException;
/**
* 按照地理地区代码查询,是否存在省份信息.
* @param regionId 地理地区Id.
* @return List.
* @throws Exception Exception.
*/
boolean isExisteProvinceByRegion(String regionId) throws Exception;
/**
* 添加单条数据.
* @param province .
* @param regionCode .
* @return boolean.
* @throws Exception .
*/
boolean saveProvince(Province province, String regionCode) throws BusinessException;
/**
* 编辑单条数据.
* @param province .
* @param regionCode .
* @throws Exception .
*/
void updateProvince(Province province, String regionCode) throws BusinessException;
/**
* 删除单条数据.
* @param clazz .
* @param provinceId .
* @return boolean.
* @throws Exception .
*/
boolean deleteProvince(Class<Province> clazz, String provinceId) throws BusinessException;
}实现类:@Service("provinceService")
public class ProvinceServiceImpl extends BaseService<Province> implements ProvinceService {
private RegionService regionService; /**
* @param regionService the regionService to set
*/
@Autowired
public void setRegionService(RegionService regionService) {
this.regionService = regionService;
}
//其他实现方法
}
@Controller
public class CountryAction extends CommonAction { /** serialVersionUID. */
private static final long serialVersionUID = 557943713629501919L; private Country country;
private CountryService countryService;
/**
* @param countryService the countryService to set
*/
@Autowired
public void setCountryService(CountryService countryService) {
this.countryService = countryService;
}
}@Controller
public class RegionAction extends CommonAction {
/** serialVersionUID. */
private static final long serialVersionUID = 557943713629501919L; private Region region;
private Country country;
private RegionService regionService; /* private CountryProvideImpl countryProvideImpl; */ /**
* @param regionService the regionService to set
*/
@Autowired
public void setRegionService(RegionService regionService) {
this.regionService = regionService;
}
}