References and built-in variables between maven-used MAVEN projects

Source: Internet
Author: User

Several of their projects often need to reference each other, if the same as Maven project, how should it be referenced?

If a project needs to refer to the jar package generated by the B project, you only need to perform a Maven install operation on the B project

After you do this, the jar package is generated in the corresponding directory in your local repo

At this point a can add the dependency in its own pom.xml file, such as:

<dependency>
<groupId>xx.xx.xx</groupId>
<artifactId>A</artifactId>
<version>0.0.1</version>
</dependency>

While most of your projects are in the same package path, you can also use MAVEN built-in variables at this time, and maven commonly built-in variables are as follows:

    • ${BASEDIR} Project root directory
    • ${project.build.directory} build directory, default to target
    • ${project.build.outputdirectory} build process output directory, default to Target/classes
    • ${project.build.finalname} output name, default is ${project.artifactid}-${project.version}
    • ${project.packaging} package type, default to Jar
    • ${PROJECT.XXX} contents of any node of the current Pom file

At this point the above dependencies can also be modified to:

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>

You can use exclusion to add subkeys in dependency when there is a dependency conflict

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-log4j12</artifactId>
</exclusion>

References and built-in variables between maven-used MAVEN projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.