错误:现场作业需要类型为“org.springframework.batch.core.Job”的 bean,但无法找到

Fao*_*eya 6 spring-batch spring-boot

我是 Spring Batch 的初学者,我用它开发了一个简单的项目。我收到错误。

Description:
Field job in com.example.demo.DemoApplication required a bean of type 
'org.springframework.batch.core.Job' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.batch.core.Job' in your 
configuration.
Run Code Online (Sandbox Code Playgroud)

这是我的代码,我只有一个类:

Description:
Field job in com.example.demo.DemoApplication required a bean of type 
'org.springframework.batch.core.Job' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.batch.core.Job' in your 
configuration.
Run Code Online (Sandbox Code Playgroud)

感谢您帮助我找到此错误的主要原因

Mah*_*ine 5

您的应用程序上下文中似乎没有Job定义 bean,或者 Spring Boot 找不到该作业。

确保您定义批处理作业的配置类位于 Spring Boot 应用程序扫描的包(或子包)中(根据com.example.demo您的示例)。