I\'m having Standalone spring batch job. This works perfectly fine when in JUNIT
@RunWith(SpringJUnit4ClassRunner.class)
//@SpringApplicationConfiguration(cl
You can solve by 2 Ways:
A.
Use spring.main.allow-bean-definition-overriding=true
in application.properties
B.
To solve spring boot batch scope issue and avoid the use of spring.main.allow-bean-definition-overriding=true
:
Disable autoProxy
of StepScope. To perform that use following code snippet as a reference:
Now perform following Spring bean configuration:
To configure step scope via XML-Based configuration:
To configure step scope via Java-Based configuration:
@StepScope
@Component(value = "userPreferences")
public class UserPreference {}