Skip to content

Instantly share code, notes, and snippets.

@o
Created May 30, 2016 16:37
Show Gist options
  • Save o/86f205c5172f40c12c63d9121b26d861 to your computer and use it in GitHub Desktop.
Save o/86f205c5172f40c12c63d9121b26d861 to your computer and use it in GitHub Desktop.

I'd done a lot of Boot projects before. But never tried multi-module structure.

Here is the my sample structure

Parent project: com.github.o.parent

Just declares org.springframework.boot-spring-boot-autoconfigure

Common project: com.github.o.common

Holds entities, repositories and repository related service classes. Only have a configuration class for HikariCP data source. Question: Which annotations (especially JPA related) right for this configuration class?

Rest project: com.github.o.rest

Depends to JPA project. Needs to use common project service classes. Also have a Application class with SpringBootApplication. Question: Same, which annotations needed for scanning common project services and repositories.

I'd tried different annotations / configurations but i can't inject a repository from common project.

Thanks.

@eruiz
Copy link

eruiz commented May 30, 2016

Imho a project organized in Maven modules will give you more or less benefits depending on the application type: monolithic or microservices.

Maybe microservices based applications can be organized in the way said by Josh ... but organizing monolithic applications in Maven modules makes the maintenance, API distribution, etc. more comfortable.

Spring Roo 2.0.0.M2 generates multimodule Spring Boot applications. Download it from http://projects.spring.io/spring-roo/, install it and run

project setup --topLevelPackage org.sprfw.petclinic --multimodule STANDARD --projectName PetClinic

You will get a nice Spring Boot multimodule project.

@wbiller
Copy link

wbiller commented May 30, 2016

Actually this also works well for monolithic applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment