java 如何从另一个 Maven 项目引用一个 Maven 项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12444413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:54:39  来源:igfitidea点击:

How to reference one maven project from another maven project?

javamaven

提问by Dante

I have an in-development library project (module by IntelliJ definition) that i want to reference from other projects. How would i go about to reference that project in other projects ?

我有一个正在开发的库项目(IntelliJ 定义的模块),我想从其他项目中引用它。我将如何在其他项目中引用该项目?

回答by Morteza Adi

you can use whether Dependency or module tags in pom.xml of your project. Depends on what you trying to do.

您可以在项目的 pom.xml 中使用 Dependency 或 module 标签。取决于你想做什么。

<dependency>
        <groupId>com.mysubpro</groupId>
        <artifactId>myproject</artifactId>
        <version>1.0-SNAPSHOT</version>
</dependency>  

Or

或者

<modules>
    <module>myproject</module>
</modules>

回答by Santosh

Not sure how much you surfed but this is very basics of Maven. Please check this example. Its a step by step example on one project being dependent on other.

不确定您浏览了多少,但这是 Maven 的基础知识。请检查这个例子。它是一个项目依赖于另一个项目的分步示例。

回答by basiljames

You have to use mvn installgoal. This will install your library to your local repository. Link to Maven Install Plugin. Once it is done you can have a dependency to it in your other projects.

你必须使用mvn install目标。这会将您的库安装到您的本地存储库。链接到Maven 安装插件。完成后,您可以在其他项目中依赖它。