Skip to content
Advertisement

The dependencies of some of the beans in the application context form a cycle in Spring Batch

I’m working on a simple Spring Batch application, and when I finished configuring it, I found that problem:

The dependencies of some of the beans in the application context form a cycle:

jobRestController defined in file [/home/yassine/Downloads/demo/target/classes/com/example/demo/JobRestController.class] springBatchConfig defined in file [/home/yassine/Downloads/demo/target/classes/com/example/demo/SpringBatchConfig.class]

Action:

Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.

The implementation of the two classes:

SpringBatchConfig:

JavaScript

JobRestController:

JavaScript

pom.xml:

JavaScript

I couldn’t fix it, and I didn’t find any similar problem on StackOverflow. Thank you in advance

Advertisement

Answer

today i had the same problem and i solve it with these steps:

  1. you should create ItemWriter,ItemProcessor Beans
  2. declare the Job bean in another config class

spring batch config

JavaScript

Job config

JavaScript

rest controller for launch the job

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement