Maven parent POM

标签 maven pom.xml parent-pom

我是Maven的新手,并且最近安装了nexus。现在,我想创建一个父POM,以便我公司中的所有项目都可以使用它。这是我的 parent POM。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>1.0.0</modelVersion>
    <groupId>com.mycomp</groupId>
    <artifactId>parent-pom-android</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>Android Parent POM</name>

    <repositories>
        <repository>
            <id>nexus-repo</id>
            <url>http://10.10.10.230:8081/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus-repo</id>
            <name>confiz-repo</name>
            <url>http://10.10.10.230:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
 </project>

现在,我应该在哪里放置该POM文件,以便我的其他POM文件可以从中继承?

最佳答案

您必须将项目部署到内部Maven存储库。为此,您首先需要配置一个Maven存储库服务器(我建议使用Apache Archiva),然后将pom.xml和settings.xml指向该服务器:http://archiva.apache.org/docs/1.4-M3/userguide/deploy.html

部署之后,您可以指向公司中的所有项目,以将该pom用作父pom。您可以使用相同的策略来创建内部项目依赖项。在continuous integration环境中,这很好。

关于Maven parent POM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400642/

相关文章:

java - 如何为我的 Maven 项目制作一个可运行的 jar?

java - 如何在Spring/Spring Boot pom.xml中指定Java版本?

eclipse - 使用 Maven pom.xml 将 War 文件部署到 Tomcat 根目录

maven - 缺少 Artifact org.springframework.boot:spring-boot-starter-parent:jar:1.3.2.RELEASE

Gradle : Something like Maven Parent POM

java - 尝试使用maven程序集插件时出现 "Assembly is incorrectly configured: null"

maven - Sonar 跳过除根模块之外的所有模块

maven - 如果它们来 self parent 的其他子模块,我应该依赖 Maven 中的传递依赖吗?

java - 在不执行 SPRING AOP 的建议之前

java - Spring boot - MongoDb 在 RepositoryInvokerFactory 上获取 ClassNotFoundException