简体   繁体   中英

Spring Boot + Batch multi module project

I am building a multi module project with Spring Boot and Batch.

The directory structure currently is:

  • core
  • web
  • batch

core contains the domain objects, repositories, services.

web contains the Spring Boot app - controllers etc

batch contains the Spring Batch app - job configurations etc

web and batch each have their own context annotated with @SpringBootApplication and I configure on execution using the start-class property eg -Dstart-class=com.company.web.WebApplication

The problem comes when including the core classes, neither app will launch due to missing bean definitions for the repositories so it sounds like component scanning is not working for the core module.

I have experimented with @SpringBootApplication(scanBasePackageClasses... and @ComponentScan(basePackageClasses... but without luck.

Any ideas what I'm missing or if there is a better way of architecting this?

I have similar structure as you do, and everything works fine. I can assume you could have following problem - packaging of your artifacts: they don't contain dependency of core jar library.

dependencies {
    compile project(':core')
}

Can you check your packaged artifacts? Do they contain core libraries?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM