Spring DATA JPA和REST存储库在单独的相关模块中(Spring Boot)

时间:2016-07-06 09:16:18

标签: spring maven spring-boot spring-data-rest

是否可以将同一实体的jpa存储库和rest存储库(注释)拆分为单独的模块?

主要pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.5.RELEASE</version>
    <relativePath/>
    <!-- lookup parent from repository -->
</parent>


<dependency>
    <groupId>a.b.c</groupId>
    <artifactId>database</artifactId>
    <version>0.0.1</version>
</dependency>

Module1(rest api)pom.xml 独特的Spring Boot App

...
<parent>
    <artifactId>a.b.c</artifactId>
    <groupId>main</groupId>
    <version>0.0.1</version>
</parent>
<packaging>war</packaging>
<dependency>
    <groupId>a.b.c</groupId>
    <artifactId>database</artifactId>
</dependency>
...

Module2(web服务)pom.xml 独特的Spring Boot App

   ...
<parent>
    <artifactId>a.b.c</artifactId>
    <groupId>main</groupId>
    <version>0.0.1</version>
</parent>
<packaging>war</packaging>
<dependency>
    <groupId>a.b.c</groupId>
    <artifactId>database</artifactId>
</dependency>
...

数据库模块pom.xml

..
<packaging>jar</packaging>
...

public interface MyJpaEntityRepository extends CrudRepository<MyEntity,String> {
}

如果我将此repo注释为@RepositoryRestResource,这将在上面的两个模块中使用不同的基本URL公开REST api ..

但是我想在Module1中启用经典的Jpa Dao(没有REST),在模块2中使用REST启用Jpa Dao

我如何配置?

0 个答案:

没有答案