配置Maven以咨询中央Maven存储库而不是Nexus

时间:2016-04-06 23:50:32

标签: maven maven-2 repository pom.xml nexus

不幸的是我的pom.xml试图从Nexus而不是maven的中央存储库下载依赖项。现在这个nexus无效,导致下载依赖项失败。

请告诉我如何指出pom.xml文件从中央存储库下载依赖项?

这是POM.XML文件

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ouch.tf</groupId>
    <artifactId>test-automation-library</artifactId>
    <version>1.2</version>
    <packaging>jar</packaging>
    <name>Test Automation Library</name>
    <description>Test Automation Library</description>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Sonar -->
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
        <sonar.language>java</sonar.language>

    </properties>

    <dependencies>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mailapi</artifactId>
            <version>1.4.3</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>smtp</artifactId>
            <version>1.4.5</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.experitest.selenium</groupId>
            <artifactId>mobile-webdriver</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>com.experitest.client</groupId>
            <artifactId>imageClient</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.util</groupId>
            <artifactId>ws-commons-util</artifactId>
            <version>1.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlrpc</groupId>
            <artifactId>xmlrpc-common</artifactId>
            <version>3.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlrpc</groupId>
            <artifactId>xmlrpc-client</artifactId>
            <version>3.1.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <!-- <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> 
            <version>4.4</version> </dependency> -->

        <!-- <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> 
            <version>2.42.2</version> </dependency> -->
        <dependency>
           <groupId>org.monte</groupId>
            <artifactId>monte-screen-recorder</artifactId>
            <version>0.7.7</version>
        </dependency>

        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>2.2.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>httpcore</artifactId>
                    <groupId>org.apache.httpcomponents</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.3</version>
        </dependency>
        <dependency>
            <groupId>org.sikuli</groupId>
            <artifactId>sikuli-webdriver</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.sikuli</groupId>
                    <artifactId>sikuli-api</artifactId>
                </exclusion>
            </exclusions>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.sikuli</groupId>
            <artifactId>sikuli-api</artifactId>
            <version>1.1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.sikuli</groupId>
                    <artifactId>sikuli-core</artifactId>
                </exclusion>
            </exclusions>

        </dependency>

        <!-- Rally Dependencies -->
        <dependency>
            <groupId>com.rallydev.rest</groupId>
            <artifactId>rally-rest-api</artifactId>
            <version>2.1.1</version>
        </dependency>
        <!-- <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> 
            <version>4.2.5</version> </dependency> -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>

        <!-- End of Rally Dependencies -->

        <dependency>
            <groupId>com.github.fge</groupId>
            <artifactId>json-schema-validator</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.8</version>

        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.48.2</version>
            <exclusions>
                <exclusion>
                    <artifactId>httpmime</artifactId>
                    <groupId>org.apache.httpcomponents</groupId>
                </exclusion>
            </exclusions>

        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>2.48.2</version>
            <exclusions>
                <exclusion>
                    <artifactId>snakeyaml</artifactId>
                    <groupId>org.yaml</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>2.48.2</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-safari-driver</artifactId>
            <version>2.48.2</version>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.9</version>
            <exclusions>
                <exclusion>
                    <artifactId>xml-apis</artifactId>
                    <groupId>xml-apis</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-scratchpad</artifactId>
            <!-- <version>3.0.1-FINAL</version> -->
            <version>3.8</version>
        </dependency>

        <!-- dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> 
            <version>3.5-beta5</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> 
            <artifactId>poi-ooxml</artifactId> <version>3.7</version> </dependency> -->
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
        </dependency>
        <!-- PDF dependency -->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.0.6</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging-api</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> 
            <version>2.1</version> </dependency> -->
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.13</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <!-- <version>20141113</version -->
            <version>20140107</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>sqljdbc</artifactId>
            <version>4-2.0</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.tfs.sdk</groupId>
            <artifactId>com.microsoft.tfs.sdk</artifactId>
            <version>11.0.0</version>
        </dependency>

        <!-- Cucumber dependencies -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>1.1.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.1.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.3</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.3</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.1</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
        </dependency>


        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
        </dependency>

        <!-- End Cucumber dependencies -->

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4.1</version>
        </dependency>


        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.4.1</version>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.8.2</version>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>1.8.2</version>
        </dependency>
        <!-- <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> 
            <version>1.7</version> </dependency> -->

        <!-- <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> 
            <version>1.7</version> </dependency> -->

        <!-- Jira Dependency -->

        <!-- compilation dependency -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-api</artifactId>
            <version>2.0.0-m31</version>
        </dependency>

        <!-- runtime dependency -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-core</artifactId>
            <version>2.0.0-m31</version>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>2.4.1</version>
        </dependency>

        <!-- End of Jira Depedendency -->

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.19</version>
        </dependency>
        <!-- <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> 
            <version>4.4-beta1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> 
            <artifactId>httpclient</artifactId> <version>4.4-beta1</version> </dependency> -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>4.2.1</version>
        </dependency>

        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>2.1.0</version>
        </dependency>

    </dependencies>

    <!-- JIRA Repository -->
    <repositories>
        <repository>
            <id>atlassian-public</id>
            <url>https://m2proxy.atlassian.com/repository/public</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
        </repository>
    </repositories>
    <!-- End of Jira Repository -->

    <build>
        <plugins>
            <!-- AspectJ plugin -->

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.7</version>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>1.8.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>1.8.2</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <complianceLevel>1.7</complianceLevel>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                        <configuration>
                            <showWeaveInfo>true</showWeaveInfo>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>


        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.12.4</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit47</artifactId>
                            <version>2.12.4</version>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-testng</artifactId>
                            <version>2.12.4</version>
                        </dependency>

                    </dependencies>
                    <configuration>

                        <systemPropertyVariables>
                            <environment>${env.USER}</environment>
                        </systemPropertyVariables>

                    </configuration>
                </plugin>

                <!-- jacoco plugins -->
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.5.5.201112152213</version>
                    <configuration>
                        <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
                        <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>jacoco-initialize</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>jacoco-site</id>
                            <phase>package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <compilerArgument>-XDignore.symbol.file</compilerArgument>
                    </configuration>

                </plugin>

                <!--This plugin's configuration is used to store Eclipse m2e settings 
                    only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.codehaus.mojo
                                        </groupId>
                                        <artifactId>
                                            aspectj-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.7,)
                                        </versionRange>
                                        <goals>
                                            <goal>test-compile</goal>
                                            <goal>compile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

我收到错误

   [ERROR] Plugin org.codehaus.mojo:aspectj-maven-plugin:1.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.7: Could not transfer artifact org.codehaus.mojo:aspectj-maven-plugin:pom:1.7 from/to nexus (http://fmsscm.corp.intit.com/nexus/content/groups/dev): null to http://fmsscm.corp.intit.com/nexus/content/groups/dev/org/codehaus/mojo/aspectj-maven-plugin/1.7/aspectj-maven-plugin-1.7.pom: UnresolvedAddressException -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 

1 个答案:

答案 0 :(得分:2)

在您的Settings.xml中,你有类似的东西,

MainWindowController.textMessageDisplay.setText("Name and password must not be empty!");

将Your.ip:port更改为<profiles> <profile> <id>Repo</id> <!-- set variable content here --> <properties> <!-- repo-ip: IP:PORT for the repository --> <repoguy-ip>YOUR.IP:PORT</repoguy-ip> </properties> <!-- download artifacts from this repo --> <repositories> <repository> <id>Repoguy</id> <name>Repoguy Nexus Public Artifacts</name> <url>http://${repoguy-ip}/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <!-- download plugins from this repo --> <pluginRepositories> <pluginRepository> <id>Repoguy</id> <name>Repoguy Nexus Public Plugins</name> <url>http://${repoguy-ip}/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> ,它应该从Maven Central加载工件和插件。如果要使用此代码,请不要忘记更改ID和发布/快照接受。

有条件的:如果您没有要部署的替代存储库,我认为您无法使用部署,直到您的nexus再次联机。

这是我在Stackoverflow上的第一个答案,如果我能做得更好,请告诉我。

EDIT-1:像khmarbaise所说,如果删除settings.xml,默认情况下Maven应该使用Maven Central。 settings.xml位于http://repo1.maven.org/maven2