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

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

How to include dependency (method) of project A into project B using maven spring

问题

  1. 我有一个Spring Boot应用程序,我的项目ACrux)有一个日志生成器类,我想在项目BBolt)中使用它。我已经在项目Bpom.xml中包含了项目A,但它仍然无法找到它。
  2. 包名:com.test.sre.crux,类名:MyLogger.withField() 在项目B中。
  3. BBolt)的pom.xml
  1. <dependency>
  2. <groupId>com.test.sre.crux</groupId>
  3. <artifactId>Crux</artifactId>
  4. <version>0.0.1-SNAPSHOT</version>
  5. </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] 构建失败

  1. ACrux)的pom.xml

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

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

  1. &lt;dependency&gt;
  2. &lt;groupId&gt;com.test.sre.crux&lt;/groupId&gt;
  3. &lt;artifactId&gt;Crux&lt;/artifactId&gt;
  4. &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  5. &lt;/dependency&gt;
  1. INFO] Scanning for projects...
  2. [INFO]
  3. [INFO] -------------------------&lt; com.apple.sre:bolt &gt;-------------------------
  4. [INFO] Building Bolt 0.0.1-SNAPSHOT
  5. [INFO] --------------------------------[ jar ]---------------------------------
  6. [WARNING] The POM for com.test.sre.crux:Crux:jar:0.0.1-SNAPSHOT is missing, no dependency information available
  7. [INFO] ------------------------------------------------------------------------
  8. [INFO] BUILD FAILURE

pom.xml of A(crux)

  1. &lt;groupId&gt;com.test.sre&lt;/groupId&gt;
  2. &lt;artifactId&gt;crux&lt;/artifactId&gt;
  3. &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  4. &lt;name&gt;crux&lt;/name&gt;
  5. &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 文件中应该相同。

  1. <groupId>com.test.sre</groupId>
  2. <artifactId>crux</artifactId>

然后,确保执行 mvn install,以便将项目 A 安装到您的本地 Maven 仓库中。

英文:

The group id and artifact id should be the same in both poms

  1. &lt;groupId&gt;com.test.sre&lt;/groupId&gt;
  2. &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:

确定