This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring batch Job launcher  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam facing issue in spring boot application.

Iam calling spring batch application in spring boot.  When i try to run the main application. iam getting below exception


***************************
APPLICATION FAILED TO START
***************************

Description:

Field job in com.boraji.tutorial.springboot.controller.HelloController 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



I have enabled @EnableBatchProcessing in my main class


Controller class :

@Controller
public class HelloController {
  @Autowired
   JobLauncher jobLauncher;

    @Autowired
    Job job;
   
@RequestMapping("/launchjob")
    public String handle() throws Exception {

        Logger logger = LoggerFactory.getLogger(this.getClass());
        try {
            JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis())
                    .toJobParameters();
            jobLauncher.run(job, jobParameters);
        } catch (Exception e) {
            logger.info(e.getMessage());
        }

        return "Done";
    }
}


Please clarify what i missed here?


 
Sheriff
Posts: 21327
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have a bean implementation of Job in your project, so when Spring Boot tries to inject the autowired Job it can't find anything to inject.
 
vinoth sathi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:You don't have a bean implementation of Job in your project, so when Spring Boot tries to inject the autowired Job it can't find anything to inject.



I have put the main java file into parent spring folder(src/main/java) and worked fine.

Dont know what is the problem. wonder how it referenced if i put into parent location.

 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!