[SpringBatch的新功能]我试图使用Spring Boot创建一个作业,该作业从MongoDB中读取名称,转换为小写字母,然后输出为CSV文件。我的阅读器和处理器正在工作,但作家没有。我的代码如下。处理器文件package bbye;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.batch.item.ItemProcessor;import org.springframework.stereotype.Component;import hello.Person;@Componentpublic class PersonDocProcessor implements ItemProcessor<Person, Person> { private static final Logger log = LoggerFactory.getLogger(PersonDocProcessor.class); @Override public Person process(final Person person) throws Exception { final String firstName = person.getFirstName().toLowerCase(); final String lastName = person.getLastName().toLowerCase(); final Person transformedPerson = new Person(firstName, lastName); log.info("Converting (" + person + ") into (" + transformedPerson + ")"); return transformedPerson; }}听众package bbye;import org.springframework.batch.core.JobExecution;import org.springframework.batch.core.JobExecutionListener;import org.springframework.stereotype.Component;@Componentpublic class FileUploadNotificationListener implements JobExecutionListener { @Override public void beforeJob(JobExecution jobExecution) { System.out.println("===== listening for job - mongoReader - fileWriter ===="); } @Override public void afterJob(JobExecution jobExecution) { System.out.println("==== file write job completed ====="); }}
添加回答
举报
0/150
提交
取消