share entities between maven projects

Viewed 902

I'm migrating one monolithic project to a microservices architecture and just for sake of make things work, I'm basically copy-pasting the model and repository classes between the projects. Turns out that I know that I can create one maven module with these classes and add it as dependency of any other project, but one thing comes to my mind: These classes are mapping of my database, and in this monolithic project, my application.yml contains all the info related to database access. If I decouple it and put this models and repositories to a separated module, where should this config lives? inside the module, inside the project that have it as dep.?

Ok, I tried a lot of things, and this is where I'm now:
I created a maven project that depends on spring boot jpa starter and added the classes (models, repos, etc) and added this project as dependency of another bigger project, but I'm seeing this error now:

[ERROR] Failed to execute goal on project github: Could not resolve dependencies for project com.inkdrop:github:jar:0.0.1-SNAPSHOT: Failure to find com.inkdrop:commons:jar:1.0-SNAPSHOT in https://repo.spring.io/snapshot was cached in the local repository, resolution will not be reattempted until the update interval of spring-snapshots has elapsed or updates are forced -> [Help 1]

it this case, commons is the project I want to add as depedency of github since it contains the models and repos

Here is my commons pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.inkdrop</groupId>
    <artifactId>commons</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Commons files</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>com.inkdrop.App</start-class>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>
                                spring-boot-starter-data-jpa
                    </artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>${spring-loaded.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

</project>
0 Answers
Related