Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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: 21421
94
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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!