Reputation: 49
spring boot 2 with maven multi-module project
how can we create JPA/entity as the separate module and add the dependency to the main project ??
I have read many links but still not find the solution, please help...
I want to create a project structure like below...
entity-project - all entity and JPA related configuration [ database and all configuration ]
master-service [ which include entity ] and repository for entity project would be here.
Please help...
Upvotes: 0
Views: 2238
Reputation: 609
This is my project structure below.
remittance-rs is the main project module that include all sub module that we define in pom.xml file like this:
<groupId>org.soyphea.remittance</groupId>
<artifactId>remittance-rs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>service</module>
<module>domain</module>
<module>remmittant-restapi</module>
</modules>
So I have 3 modules that include service is for our logic, domain for our DAO and Domain and the last one restapi for our exposed rest endpoint.
So all the sub module need to include the parent artifact and group id like below,
<parent>
<groupId>org.soyphea.remittance</groupId>
<artifactId>remittance-rs</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
In your sub module you gonna need dependencies individual for each of them.
Example
domain module pom.xml will need spring-boot-starter-data-jpa let's see detail.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.soyphea.remittance</groupId>
<artifactId>remittance-rs</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.soyphea.domain</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
</dependencies>
</project>
This is my sample project in github https://github.com/PheaSoy/spring-boot-remittance-project
Upvotes: 1