简体   繁体   English

如何从另一个maven项目引用一个maven项目?

[英]How to reference one maven project from another maven project?

I have an in-development library project (module by IntelliJ definition) that i want to reference from other projects. 我有一个开发中的库项目(IntelliJ定义模块),我想从其他项目中引用。 How would i go about to reference that project in other projects ? 我将如何在其他项目中引用该项目?

you can use whether Dependency or module tags in pom.xml of your project. 您可以在项目的pom.xml中使用Dependency或module标签。 Depends on what you trying to do. 取决于你想做什么。

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

Or 要么

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

Not sure how much you surfed but this is very basics of Maven. 不知道你有多少冲浪,但这是Maven的基础知识。 Please check this example . 检查此示例 Its a step by step example on one project being dependent on other. 它是一个一步一步的例子,一个项目依赖于其他项目。

You have to use mvn install goal. 你必须使用mvn install目标。 This will install your library to your local repository. 这会将您的库安装到本地存储库。 Link to Maven Install Plugin . 链接到Maven安装插件 Once it is done you can have a dependency to it in your other projects. 完成后,您可以在其他项目中依赖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM