This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Spring batch Job launcher  RSS feed

 
Greenhorn
Posts: 18
  • 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: 21612
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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: 18
  • 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.

 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!