Maven Clean 问题 - 无法解析的导入 POM - 无法从 NEXUS 传输工件

问题描述 投票:0回答:4

我在构建新项目时遇到问题。 该构建适用于项目的旧开发人员,但在克隆项目并使用相同版本的 Maven 之后。它对我不起作用。

最初,我正在执行 mvn clean install

但是,经过一些研究,我发现简单的 mvn clean 也会发生相同的构建错误。

错误如下:

C:\workspace\some-web-app>mvn clean
[INFO] Scanning for projects...
Downloading from nexus-public: https://company-net:8080/nexus/content/groups/public/org/jboss/bom/jboss-eap-javaee7-with-tools/7.1.0.GA/jboss-eap-javaee7-with-tools-7.1.0.GA.pom
Downloading from nexus-releases: https://company-net:8080/nexus/content/repositories/releases/org/jboss/bom/jboss-eap-javaee7-with-tools/7.1.0.GA/jboss-eap-javaee7-with-tools-7.1.0.GA.pom
Downloading from nexus-public: https://company-net:8080/nexus/content/groups/public/org/jboss/bom/eap-runtime-artifacts/7.1.0.GA/eap-runtime-artifacts-7.1.0.GA.pom
Downloading from nexus-releases: https://company-net:8080/nexus/content/repositories/releases/org/jboss/bom/eap-runtime-artifacts/7.1.0.GA/eap-runtime-artifacts-7.1.0.GA.pom
Downloading from nexus-public: https://company-net:8080/nexus/content/groups/public/org/jboss/spec/jboss-javaee-7.0/1.1.0.Final-redhat-1/jboss-javaee-7.0-1.1.0.Final-redhat-1.pom
Downloading from nexus-releases: https://company-net:8080/nexus/content/repositories/releases/org/jboss/spec/jboss-javaee-7.0/1.1.0.Final-redhat-1/jboss-javaee-7.0-1.1.0.Final-redhat-1.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-ejb-plugin is missing. @ line 292, column 22
[ERROR] Non-resolvable import POM: Could not transfer artifact org.jboss.bom:jboss-eap-javaee7-with-tools:pom:7.1.0.GA from/to nexus-public (https://company-net:8080/nexus/content/groups/p
[ERROR] Non-resolvable import POM: Could not transfer artifact org.jboss.bom:eap-runtime-artifacts:pom:7.1.0.GA from/to nexus-public (https://company-net:8080/nexus/content/groups/public/)
[ERROR] Non-resolvable import POM: Could not transfer artifact org.jboss.spec:jboss-javaee-7.0:pom:1.1.0.Final-redhat-1 from/to nexus-public (https://company-net:8080/nexus/content/groups/
[ERROR] 'dependencies.dependency.version' for javax.enterprise:cdi-api:jar is missing. @ line 136, column 21
[ERROR] 'dependencies.dependency.version' for org.hibernate:hibernate-core:jar is missing. @ line 142, column 21
[ERROR] 'dependencies.dependency.version' for org.hibernate:hibernate-validator:jar is missing. @ line 148, column 21
[ERROR] 'dependencies.dependency.version' for org.hibernate:hibernate-ehcache:jar is missing. @ line 160, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec:jar is missing. @ line 165, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.faces:jboss-jsf-api_2.2_spec:jar is missing. @ line 171, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:jar is missing. @ line 177, column 21

settings.xml位于C:\Users[User-ID].m2下,如下:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <pluginGroups />
    <proxies />
    <servers>

        <server>
          <id>nexus-public</id>
          <username>user1</username>
          <password>pass1</password>
        </server>
        <server>
          <id>nexus-snapshots</id>
          <username>user1</username>
          <password>pass1</password>
        </server>
        <server>
          <id>nexus-releases</id>
          <username>user1</username>
          <password>pass1</password>
        </server>

    </servers>

    <mirrors />

    <profiles>
        <profile>
            <id>companydev</id>

            <properties>
                <unit-test-ldap-server-host>mis-dev</unit-test-ldap-server-host>
                <unit-test-database-url>jdbc:mysql://mis-dev:1234/unit_test</unit-test-database-url>
            </properties>

            <repositories>
                <repository>
                    <id>nexus-public</id>
                    <url>https://company-net:8080/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>nexus-snapshots</id>
                    <url>https://company-net:8080/nexus/content/repositories/snapshots</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>nexus-releases</id>
                    <url>https://company-net:8080/nexus/content/repositories/releases</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>companydev</activeProfile>
    </activeProfiles>

</settings>

要构建的模块的 POM 是:

<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>4.0.0</modelVersion>

    <groupId>sc.foc.fo.plc</groupId>
    <artifactId>ams-parent</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <name>ags</name>
    <description>desc  .........</description>
    <organization>
        <name>Org Name</name>
    </organization>

    <distributionManagement>
        <repository>
            <id>deployment</id>
            <name>Internal Releases</name>
            <url>http://1.2.3.4:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>deployment</id>
            <name>Internal Releases</name>
            <url>http://1.2.3.4:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>

        <!-- Explicitly declaring the source encoding eliminates the following
            message: [WARNING] Using platform encoding (UTF-8 actually) to copy
            filtered resources, i.e. build is platform dependent! -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <commons-lang.version>2.4</commons-lang.version>

        <deltaspike.version>1.8.0</deltaspike.version>

        <jboss-spec-javaee-7.0.version>1.1.0.Final-redhat-1</jboss-spec-javaee-7.0.version>
        <primefaces.version>6.1</primefaces.version>
        <server-bom.version>7.1.0.GA</server-bom.version>

        <!-- EAP7 version, according to https://stackoverflow.com/questions/38688392/slf4j-logging-with-jboss-wildfly-10 -->
        <slf4j.version>1.7.7</slf4j.version>
        <wildfly-maven-plugin.version>1.2.0.Alpha4</wildfly-maven-plugin.version>

        <commons-io.version>2.4</commons-io.version>

        <swagger-core-v3.version>2.0.2</swagger-core-v3.version>
        <swagger-model-v3.version>2.0.2</swagger-model-v3.version>
        <swagger-codegen-maven-plugin.version>2.3.1</swagger-codegen-maven-plugin.version>
        <swagger-core.version>1.5.16</swagger-core.version>

        <cxf-rt-frontend-jaxrs.version>3.1.12</cxf-rt-frontend-jaxrs.version>
        <cxf-version>3.1.11</cxf-version>

        <junit.version>4.12</junit.version>
        <mysql-connector.version>5.1.45</mysql-connector.version>

        <jackson-version>1.9.2</jackson-version>
        <jax-rs-version>1.1.1</jax-rs-version>
        <json4s-jackson-version>3.2.4</json4s-jackson-version>
        <json4s-core-version>3.0.0</json4s-core-version>
        <fasterxml-json-version>2.8.9</fasterxml-json-version>
        <scala-lang-version>2.9.1-1</scala-lang-version>
        <reflections-version>0.9.9-RC1</reflections-version>
        <javassist-version>3.16.1-GA</javassist-version>
        <paranamer-version>2.5.2</paranamer-version>
        <scannotation-version>1.0.3</scannotation-version>
        <swagger-version>1.5.1-M2</swagger-version>
        <resteasy-jaxrs-version>3.0.24.Final</resteasy-jaxrs-version>
        <javax-servlet-version>3.1.0</javax-servlet-version>
        <mockito.version>1.10.19</mockito.version>
        <slf4j.version>1.7.7</slf4j.version>

    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- JBoss distributes a complete set of Java EE APIs including a Bill
                of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection)
                of artifacts. We use this here so that we always get the correct versions
                of artifacts. Here we use the jboss-eap-javaee7-with-tools stack (you can
                read this as the JBoss stack of the Java EE APIs, with some extras tools
                for your project, such as Arquillian for testing) -->
            <dependency>
                <groupId>org.jboss.bom</groupId>
                <artifactId>jboss-eap-javaee7-with-tools</artifactId>
                <version>${server-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.bom</groupId>
                <artifactId>eap-runtime-artifacts</artifactId>
                <version>${server-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Define the version of the JBoss Java EE APIs we want to use -->
            <!-- JBoss distributes a complete set of Java EE APIs including
               a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
               a collection) of artifacts. We use this here so that we always get the correct
               versions of artifacts. Here we use the jboss-javaee-7.0 stack (you can
               read this as the JBoss stack of the Java EE APIs). You can actually
               use this stack with any version of JBoss EAP that implements Java EE. -->
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-7.0</artifactId>
                <version>${jboss-spec-javaee-7.0.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.as</groupId>
                <artifactId>jboss-as-cli</artifactId>
                <version>7.2.0.Final</version>
                <exclusions>
                    <!-- we exclude this because it's locally resolved at runtime, yet the dependency plugin attempts to download it -->
                    <exclusion>
                        <groupId>sun.jdk</groupId>
                        <artifactId>jconsole</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>${primefaces.version}</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>all-themes</artifactId>
            <version>1.0.10</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <scope>provided</scope>
            <version>${slf4j.version}</version>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>${commons-lang.version}</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>

        <!-- test -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>

        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>2.5.4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql-connector.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>nl.geodienstencentrum.maven</groupId>
                <artifactId>sass-maven-plugin</artifactId>
                <!-- Cannot use a later version! it uses classes that are incompatible
                     with the maven deploy plugin, and this can't be easily resolved
                     e.g. see https://stackoverflow.com/questions/43630262/how-to-exclude-a-direct-dependency-of-a-maven-plugin -->
                <version>2.25</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4</version>
                <!--
                <configuration>
                    <systemProperties>
                        <property>
                            <name>unit-test-ldap-server-host</name>
                            <value>${unit-test-ldap-server-host}</value>
                        </property>
                        <property>
                            <name>unit-test-database-url</name>
                            <value>${unit-test-database-url}</value>
                        </property>
                    </systemProperties>
                </configuration>
                -->
            </plugin>

            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.4</version>
            </plugin>

            <!-- plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                </configuration>
            </plugin-->

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ejb-plugin</artifactId>
                    <version>3.0.1</version>
                    <configuration>
                        <ejbVersion>3.0</ejbVersion>
                    </configuration>
            </plugin>


             <!--

            To be able to share a single suppression files, regardless of how
            maven is ran, we can't have this plugin running in the parent pom
            (it has a circular dependency on the build-tools module).

            Therefore, each module that should have dependencies checked
            should include this plugin

            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            Has been disabled temporarily as the suppression of vulnerabilities CVE-2017-7656, CVE-2017-7658, CVE-2017-7657 and
            CVE-2017-9735 do not work resulting in a Jenkins build failure.

            Developers should uncomment this section, change the phase to compile below and run a standard mvn clean install whenever new
            dependencies have been added in a pom to ensure that no further vulnerabilities are added or at least new suppressions are 
            added.
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            -->
            <!--plugin>
                <groupId>org.owasp</groupId>
                <artifactId>dependency-check-maven</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>

                            <cveValidForHours>96</cveValidForHours>
                            <failBuildOnCVSS>7</failBuildOnCVSS>
                            <suppressionFile>build-tools/dep-check-supression.xml</suppressionFile>
                            <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>sc.foc.fo.plc</groupId>
                        <artifactId>ags-build-tools</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin-->
        </plugins>
    </build>

    <modules>
        <module>ags-build-tools</module>
        <module>ags-core</module>
        <module>ags-core-api</module>
        <module>ags-jpa</module>
        <module>ags-integration-authorise-api</module>
        <module>ags-integration-authorise-api-impl</module>
        <module>ags-integration-jboss</module>
        <module>ags-database</module>
        <module>ags-web</module>
    </modules>

</project>

我在 POM 中添加了最新版本的依赖项,以修复与“'dependency.dependency.version'”相关的 7 个错误。但是,我的同事不必将该版本添加到他们的版本中。所以,我的 hack 是不可接受的!依赖项的范围为“提供”,并且应由容器提供。经过研究,我了解到依赖项应该下载到我的 .m2 (本地存储库)中以进行本地构建,但不应在 buld 期间将它们打包到最终的工件中。

此外,第二个仍未解决的问题是“不可解析的导入 POM:无法传输工件”。我认为这是一个代理问题,但我的同事认为使用我的移动热点应该可以。任何想法将不胜感激。谢谢。

你知道可能是什么问题吗?

java spring maven jboss nexus
4个回答
0
投票

您的

dependencyManagement
下没有此条目,同样为您的所有依赖项执行此操作。版本应添加在
dependencyManagement
上或直接在
dependencies

<dependencyManagement>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <scope>provided</scope>
        <version>whatever-version-you-need</version>
    </dependency>
</dependencyManagement>

0
投票

如果老开发人员可以构建,而您不能,这意味着老开发人员在其本地 Maven 缓存/存储库中有一些工件,而您没有。您可能需要

-Pcompanydev
来查看本地存储库管理器。


0
投票

谢谢大家,这个问题通过连接到我的家庭wifi(没有公司防火墙、代理等)得到了解决,所以我能够进一步下载依赖项,但后来我遇到了另一个问题,我将提出一个新问题。谢谢。


0
投票

感谢大家的贡献和时间。

支持团队将我的机器列入白名单并使用公司 WiFi 解决了问题。 公司代理阻止从某些站点下载依赖项也可能会出现类似的问题。您可以在 Maven settings.xml 中更新代理设置。

© www.soinside.com 2019 - 2024. All rights reserved.