我开发了Spring Boot-Batch代码并sonarlint/Sonar-Qube给出了以下错误。我浏览了链接,但根据此链接无法理解解决方案:https ://rules.sonarsource.com/java/tag/spring/RSPEC-3305 。
将此字段值直接注入“studentStepOne”,这是唯一使用它的方法。
代码:
@Configuration
@PropertySource("classpath:application.properties")
public class StudentJob {
@Value( "${spring.chunk.size}")
private String chunkSize;
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Autowired
private JdbcCursorItemReader<Student> StudentReader;
@Autowired
private ItemProcessor<Student, Student> StudentProcessor;
@Autowired
private StudentWriter StudentWriter;
@Bean
public StudentStepExecuListner StudentStepExecuListner() {
return new StudentStepExecuListner();
}
@Bean("readStudentJob")
@Primary
public Job readStudentJob() {
return jobBuilderFactory.get("readStudentJob")
.incrementer(new RunIdIncrementer())
.start(StudentStepOne())
.build();
}
@Bean
public Step StudentStepOne() {
return stepBuilderFactory.get("StudentStepOne")
.<Student, Student>chunk(Integer.parseInt(chunkSize))
.reader(StudentReader)
.processor(StudentProcessor)
.writer(StudentWriter)
.listener(StudentStepExecuListner())
.build();
}
}
青春有我
呼啦一阵风
白猪掌柜的
相关分类