如何使用Maven Spring将项目A的依赖项(方法)引入项目B中

huangapple go评论69阅读模式
英文:

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:

com.test.sre
crux
0.0.1-SNAPSHOT
crux
存储所有关键指标和可用性的仓库

我还尝试了包含构建路径,请提供建议。[![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)

		&lt;dependency&gt;
            &lt;groupId&gt;com.test.sre.crux&lt;/groupId&gt;
            &lt;artifactId&gt;Crux&lt;/artifactId&gt;
            &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;/dependency&gt;
INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------&lt; com.apple.sre:bolt &gt;-------------------------
[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)

	&lt;groupId&gt;com.test.sre&lt;/groupId&gt;
	&lt;artifactId&gt;crux&lt;/artifactId&gt;
	&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
	&lt;name&gt;crux&lt;/name&gt;
	&lt;description&gt;Repo for all the key metrics and usabilities&lt;/description&gt;

I have also tried to include build path, please suggest.如何使用Maven Spring将项目A的依赖项(方法)引入项目B中

答案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

&lt;groupId&gt;com.test.sre&lt;/groupId&gt;
&lt;artifactId&gt;crux&lt;/artifactId&gt;

Then, make sure you do a mvn install, so you have project A in your local maven repository.

huangapple
  • 本文由 发表于 2020年8月28日 20:34:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/63633890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定