Quantcast
Channel: OKWAVE 閲覧数の多い質問(Java/253)【本日】
Viewing all articles
Browse latest Browse all 68675

java spring でエラーが出て困ってます

$
0
0
spring 超初心者です。cloudfoundyでcronを実行しようとしています。 CronService から@Autowiredで、StartJob_cを呼び出し 更に呼び出されたStartJob_cから、@AutowiredでReadFile_cを呼び出そうとしています。 しかし、Injection of autowired dependencies failed; nested exception というエラーが出て動きません。 質問1)このような、呼び出しはできないのでしょうか? 質問2)springでこのような、呼び出しをしたい場合、どうするのが良いのでしょうか? エラー内容は、 [ERROR] [main 11:08:03] (ContextLoader.java:initWebApplicationContext:220) Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.krams.tutorial.job.StartJob org.krams.tutorial.job.CronService.startJob; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'syncStartJob': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.krams.tutorial.job.ReadFile org.krams.tutorial.job.StartJob_c.readFile_cService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.krams.tutorial.job.ReadFile] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} です。 ロジックサンプルは、以下の通りです。 @Service public class CronService implements Cron{ protected static Logger logger = Logger.getLogger("service"); @Autowired @Qualifier("syncStartJob") private StartJob startJob; @Scheduled(cron="*/10 * * * * ?") public void doSchedule() { logger.debug("cron"); startJob.jobExec(); } } @Component("syncStartJob") public class StartJob_c implements StartJob{ protected static Logger logger = Logger.getLogger("service"); //@Autowired //private StartJob2 startJob2_cService; @Autowired private ReadFile readFile_cService; @Autowired private DeleteFile deleteFile_cService; @Autowired private ShinchokuFile1LineDel shinchokuFile1LineDel_cService; public void jobExec() { // TODO Auto-generated method stub logger.debug("StartJob"); List<String> strYMDStartArray = new ArrayList(); strYMDStartArray.add("20060701");//0 1 strYMDStartArray.add("20060501");//1 2 strYMDStartArray.add("20060301");//2 3 strYMDStartArray.add("20060101");//3 4 strYMDStartArray.add("20051101");//4 5 strYMDStartArray.add("20050901");//5 6 String strFileName = ""; List<Integer> AYMDCNTData = new ArrayList(); strFileName = "YMDCNT"; AYMDCNTData = this.readFile_cService.readIntData(strFileName); int intYMDCNT = AYMDCNTData.size(); List<Integer> ACNTData = new ArrayList(); strFileName = "JobCNT"; ACNTData = this.readFile_cService.readIntData(strFileName); int intJobCNT = ACNTData.size(); String strYMDStart = ""; String strYMDEnd = ""; int intYMDID = 0; int intJobCounter = 11; intJobCounter = intJobCounter + intJobCNT; String sTrailJoken_start = ""; String sTrailJoken_end = ""; String sTrailGaku_start = ""; String sTrailGaku_end = ""; if( intJobCounter == 11){ sTrailJoken_start = "10"; sTrailJoken_end = "10"; sTrailGaku_start = "5000"; sTrailGaku_end = "5000"; }else if(intJobCounter == 12){ sTrailJoken_start = "10"; sTrailJoken_end = "10"; sTrailGaku_start = "10000"; sTrailGaku_end = "10000"; }else if(intJobCounter == 13){ sTrailJoken_start = "10"; sTrailJoken_end = "10"; sTrailGaku_start = "15000"; sTrailGaku_end = "15000"; }else if(intJobCounter == 14){ sTrailJoken_start = "10"; sTrailJoken_end = "10"; sTrailGaku_start = "20000"; sTrailGaku_end = "20000"; }

Viewing all articles
Browse latest Browse all 68675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>