I have 2 spring-boot applications. 1. search-engine, 2. post-engine. I am trying to include the search-engine jar into the post-engine POM file.
Here is my search-engine POM file.
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.askvedicastrologers</groupId>
<artifactId>search-engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>search-engine</name>
<packaging>jar</packaging>
<description>search-engine project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Here is my post-engine POM file.
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.askvedicastrologers</groupId>
<artifactId>post-engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>post-engine</name>
<description>post-engine project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
***<dependency>
<groupId>com.askvedicastrologers</groupId>
<artifactId>search-engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>***
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
After I mvn clean install the search-engine project, I am doing mvn clean install of post-engine which includes search-engine jar. The build is also successful. The issue is that if I try to use any service or any classes from the search-engine service inside the post-engine service, it cannot import it.
What configuration am I missing?
CodePudding user response:
try to manage your two projects like modules. Create a root project that will contain the two projects and declare in the parent pom your current projects like modules.
E.g. https://spring.io/guides/gs/multi-module/
CodePudding user response:
Anyway, I created a base project and included these 2 projects in its POM.
Gave the packaging as POM <packaging>pom</packaging>
.
<modules>
<module>../search-engine</module>
<module>../post-engine</module>
</modules>
<dependencies>
<!-- Search-Engine module dependency -->
<dependency>
<groupId>com.askvedicastrologers</groupId>
<artifactId>search-engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- Post-Engine module dependency -->
<dependency>
<groupId>com.askvedicastrologers</groupId>
<artifactId>post-engine</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>