英文:
How to include dependency (method) of project A into project B using maven spring
问题
我有一个Spring Boot应用程序,我的项目A(Crux)有一个日志生成器类,我想在项目B(Bolt)中使用它。我已经在项目B的pom.xml中包含了项目A,但它仍然无法找到它。
包名:com.test.sre.crux,类名:MyLogger.withField() 在项目B中。
B(Bolt)的pom.xml:
<dependency>
<groupId>com.test.sre.crux</groupId>
<artifactId>Crux</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
[INFO] 正在扫描项目...
[INFO]
[INFO] -------------------------< com.apple.sre:bolt >-------------------------
[INFO] 构建 Bolt 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] 未找到 com.test.sre.crux:Crux:jar:0.0.1-SNAPSHOT 的 POM 文件,无法获取依赖信息
[INFO] ------------------------------------------------------------------------
[INFO] 构建失败
A(Crux)的pom.xml:
我还尝试了包含构建路径,请提供建议。[![enter image description here][1]][1]
英文:
I have a Spring boot application, My Project A(crux) has a Log generator class which I want to use in project B(bolt). I have included project A in the pom.xml of Project B but still its not able to find that.
package : com.test.sre.crux & class : MyLogger.withField() in project B
pom.xml of B(bolt)
<dependency>
<groupId>com.test.sre.crux</groupId>
<artifactId>Crux</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.apple.sre:bolt >-------------------------
[INFO] Building Bolt 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.test.sre.crux:Crux:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
pom.xml of A(crux)
<groupId>com.test.sre</groupId>
<artifactId>crux</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>crux</name>
<description>Repo for all the key metrics and usabilities</description>
答案1
得分: 1
以下是翻译好的内容:
群组 ID 和构件 ID 在两个 POM 文件中应该相同。
<groupId>com.test.sre</groupId>
<artifactId>crux</artifactId>
然后,确保执行 mvn install
,以便将项目 A 安装到您的本地 Maven 仓库中。
英文:
The group id and artifact id should be the same in both poms
<groupId>com.test.sre</groupId>
<artifactId>crux</artifactId>
Then, make sure you do a mvn install, so you have project A in your local maven repository.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论