无法在另一个POM Spring Boot应用程序中导入Spring Boot Jar文件
我有2个弹簧启动应用程序。 1。搜索引擎,2。后发动机。我试图将搜索引擎罐中的搜索引擎罐中的POM文件包括在内。
这是我的搜索引擎POM文件。
<?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>
这是我的后发动机文件。
<?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>
MVN CLAIN安装搜索引擎项目后,我正在执行包括搜索引擎罐子在内的MVN清洁后安装。构建也是成功的。问题是,如果我尝试在后发动机服务中使用搜索引擎服务中的任何服务或任何类,则无法导入它。
我缺少什么配置?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试管理您的两个项目,例如模块。创建一个根项目,该项目将包含两个项目并在您当前的POM(例如模块)中声明。
例如 https://spring.io/guides/guides/guides/guides/ggs/multi-module/
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/
无论如何,我创建了一个基本项目,并将这两个项目包括在其POM中。
将包装作为POM
&lt; packaging&gt; pom&lt;/packaging&gt;
。Anyway, I created a base project and included these 2 projects in its POM.
Gave the packaging as POM
<packaging>pom</packaging>
.