无法从stepexecutionlistener中的applications.properties文件访问值

brc7rcf0  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(287)

在spring批处理中,我尝试从 application.properties 文件在我的 StepExecutionListener 使用Spring @value 注解,但结果是 null .

  1. public class SomeListener implements StepExecutionListener {
  2. @Value("${some.property}")
  3. private String foo;
  4. @Override
  5. public void beforeStep(StepExecution stepExecution) {
  6. System.out.println(foo);
  7. }
  8. }

这段代码打印 null .

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题