关于spring的@Autowired 时的异常
在公司做项目中碰到的一些从没有遇到的异常;
公司使用的是注解方式进行sping 的依赖注入;模块间的调用通过接口实现;
这是接口:
里面定义供调用的方法,方法已经被别的模块的类实现;
public interface IFcIntrestDtlService {
?
??? public double? calculateSumInterest(Date startDate, Date endDate,int interestType,String accTypeCode,String corpCode,String curCode);
?
??? List<DecisionFuncValue> calculateSumInterest(Date startDate, Date endDate,int isNetSign);
?
??? List<DecisionFuncValue> calculateLxzc(Date startDate, Date endDate, int netSign);
}
?
这是依赖接口的调入类,调入类负责定义接口调用接口中的方法;
@Transactional
@Service("decisionImportService")
public class DecisionImportService {
??? /**
???? * 币别service
???? */
??? @Autowired(required = false)
??? private IBtCurrencyService iBtCurrencyService;
???
???
??? /**
???? *
???? */
??? @Autowired(required = false)
??? IBtUserManagerServcies iBtUserManagerServcies;
如果接口中的方法实现不存在,就是别的模块没有被加载进当前项目中。那么就要设置这个属性:在程序启动时不加载这个依赖的接口和模块
????
??? @Autowired(required = false)
??? private IFcIntrestDtlService iFcIntrestDtlService;
??? @Autowired(required = false)
??? private IFcAccBalanceService iFcAccBalanceService;
?
??? /**
???? *
???? */
??? @Autowired
??? IBtCorpService iBtCorpService;
??? /**
???? * 网点的service
???? */
??? @Autowired
??? private IBtNetService iBtNetService;
??? @Autowired(required = false)
??? private IFcSubjectDayService iFcSubjectDayService;
???
??? @Autowired(required = false)
??? private IFcSubjectService iFcSubjectService;
??? public IFcSubjectService getIFcSubjectService() {
??????? return iFcSubjectService;
??? }
??? public void setIFcSubjectService(IFcSubjectService iFcSubjectService) {
??????? this.iFcSubjectService = iFcSubjectService;
??? }
??? public IFcSubjectDayService getIFcSubjectDayService() {
??????? return iFcSubjectDayService;
??? }
??? public void setIFcSubjectDayService(IFcSubjectDayService iFcSubjectDayService) {
??????? this.iFcSubjectDayService = iFcSubjectDayService;
??? }
??? public IFcIntrestDtlService getIFcIntrestDtlService() {
??????? return iFcIntrestDtlService;
??? }
??? public void setIFcIntrestDtlService(IFcIntrestDtlService iFcIntrestDtlService) {
??????? this.iFcIntrestDtlService = iFcIntrestDtlService;
??? }
??? public IBtCorpService getIBtCorpService() {
??return iBtCorpService;
?}
??? public IFcAccBalanceService getIFcAccBalanceService() {
??????? return iFcAccBalanceService;
??? }
??? public void setIFcAccBalanceService(IFcAccBalanceService iFcAccBalanceService) {
??????? this.iFcAccBalanceService = iFcAccBalanceService;
??? }
??? public void setIBtCorpService(IBtCorpService btCorpService) {
??iBtCorpService = btCorpService;
?}
?public IBtCurrencyService getIBtCurrencyService() {
??return iBtCurrencyService;
?}
?public void setIBtCurrencyService(IBtCurrencyService btCurrencyService) {
??iBtCurrencyService = btCurrencyService;
?}
?public IBtUserManagerServcies getIBtUserManagerServcies() {
??return iBtUserManagerServcies;
?}
?public void setIBtUserManagerServcies(
???IBtUserManagerServcies btUserManagerServcies) {
??iBtUserManagerServcies = btUserManagerServcies;
?}
?public IBtNetService getIBtNetService() {
??return iBtNetService;
?}
?public void setIBtNetService(IBtNetService btNetService) {
??iBtNetService = btNetService;
?}
}
?