简体   繁体   English

Spring Boot 2 +实体/ jpa作为子模块

[英]spring boot 2 + entity/jpa as sub module

spring boot 2 with maven multi-module project Spring Boot 2与Maven多模块项目

how can we create JPA/entity as the separate module and add the dependency to the main project ?? 我们如何创建JPA /实体作为单独的模块,并将依赖项添加到主项目中?

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 ] 实体项目-所有实体和与JPA相关的配置[数据库和所有配置]

master-service [ which include entity ] and repository for entity project would be here. 主服务(包括实体)和实体项目的存储库将在此处。

Please help... 请帮忙...

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: remittance-rs是主要项目模块,其中包括我们在pom.xml文件中定义的所有子模块,如下所示:

<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. 所以,我有3个模块,其中包括服务是我们的逻辑,为我们的DAO和领域,并为我们曝光休息终点最后一个RESTAPI

So all the sub module need to include the parent artifact and group id like below, 因此,所有子模块都需要包含父产品和组ID,如下所示,

<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. 模块pom.xml将需要spring-boot-starter-data-jpa,让我们看看详细信息。

<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 这是我在github https://github.com/PheaSoy/spring-boot-remittance-project中的 示例项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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