0

I have a spring STS project which depends on two other projects in the same workspace. I have included them in my pom.xml but when I build jar they are excluded from the generated jar.Could you please let me know how to include these two dependent projects in the build.

I have below entries in pom.xml

<dependencies>
        <dependency>
            <groupId>org.acord.standards.life</groupId>
            <artifactId>txlife</artifactId>
            <version>2.37.00</version>
        </dependency>
        <dependency>
            <groupId>com.xxx.service.query</groupId>
            <artifactId>queryutil</artifactId>
            <version>1.0</version>
        </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.acord.standards.life</groupId>
            <artifactId>txlife</artifactId>
            <version>2.37.00</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>com.xxx.service.query</groupId>
            <artifactId>queryutil</artifactId>
            <version>1.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <attach>true</attach>
                <!-- <includes>
                    <include>
                        <groupId>org.acord.standards.life</groupId>
                        <artifactId>txlife</artifactId>
                        <version>2.37.00</version>
                        <classifier>2.37.00</classifier>
                    </include>
                    <include>
                        <groupId>com.xxx.service.query</groupId>
                        <artifactId>queryutil</artifactId>
                        <version>1.0</version>
                        <classifier>1.0</classifier>
                    </include>
                </includes> -->
            </configuration>
        </plugin>
   </plugins>
</build>
Debopam
  • 3,198
  • 6
  • 41
  • 72

1 Answers1

0

I solve this problem following this documentation from Spring.io.

An alternative approach is you run Maven Install for each dependency project and, after it, set them in your pom.xml (in your main project). For example, I have a main spring project called Alna Rest that depends of others particular spring projects how Alna Data and Alna Service, then, in my Alna Rest project my pom.xml has this:

    <dependency>
        <groupId>com.alna.data</groupId>
        <artifactId>alna-data</artifactId>
        <version>0.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.alna.service</groupId>
        <artifactId>alna-service</artifactId>
        <version>0.0.1</version>
    </dependency>

After it I can run Maven Install in my Alna Rest project that the Spring Boot Maven Plugin build an executable jar with all projects dependencies.

Well, this works for me. But I don't know if it is the better approach for build a project that requires many othes spring boot projects. Then I recommend you search more about this.

Filipe Luchini
  • 351
  • 3
  • 7