2012-09-14 59 views
2

我刚刚在我们的一台开发机器上安装了Nexus 2.1.2,我想将它用作中央存储库的代理,并且将其用作我们快照和发布的内部存储库。我试图从Sonatype的示例中了解如何设置它,但是我一直在我的POM中收到一堆错误(我正在使用Eclipse和m2e)。下面是错误的:无法让Maven与Nexus OSS合作

无插件在当前的项目和可从资料库中 插件组[]发现前缀“战争” [本地 (C:\用户\ jwolinsk.m2 \库) ,承上启下 (HTTP:// xxxxxxdev9:8081 /关系/内容/库/组/公共)]

无插件从当前项目,并在 插件组[]可发现前缀“战争”存储库[local (C:\ Users \ jwolinsk.m2 \ repository),nexus (http:// jc1lkddev9:8081/nexus/content/repositories/groups/public)]

这里是我的settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> 
    <proxies> 
     <proxy> 
      <active>true</active> 
      <protocol>http</protocol> 
      <port>8080</port> 
      <host>xxxxprxy2</host> 
      <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> 
      <id>httpProxy</id> 
     </proxy> 
    </proxies> 
    <mirrors> 
     <mirror> 
      <id>nexus</id> 
      <mirrorOf>*</mirrorOf> 
      <url>http://xxxxxdev9:8081/nexus/content/repositories/groups/public</url> 
     </mirror> 
    </mirrors> 
    <profiles> 
     <profile> 
      <id>local</id> 
      <repositories> 
       <repository> 
        <id>central</id> 
        <url>http://central</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </repository> 
      </repositories> 
      <pluginRepositories> 
       <pluginRepository> 
        <id>central</id> 
        <url>http://central</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </pluginRepository> 
      </pluginRepositories> 
     </profile> 
    </profiles> 
    <activeProfiles> 
     <activeProfile>local</activeProfile> 
    </activeProfiles> 
</settings> 

这里是我的pom.xml:

<?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>4.0.0</modelVersion> 
    <groupId>com.ks</groupId> 
    <artifactId>kdweb</artifactId> 
    <name>kdweb</name> 
    <packaging>war</packaging> 
    <version>1.0.0-BUILD-SNAPSHOT</version> 
    <parent> 
     <groupId>org.sonatype.oss</groupId> 
     <artifactId>oss-parent</artifactId> 
     <version>7</version> 
    </parent> 
    <properties> 
     <org.springframework-version>3.1.2.RELEASE</org.springframework-version> 
     <org.slf4j-version>1.5.10</org.slf4j-version> 
    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${org.springframework-version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.ks</groupId> 
      <artifactId>acommons</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
     </dependency> 
     <dependency> 
      <groupId>com.ks</groupId> 
      <artifactId>aggregation-common</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-dbcp</groupId> 
      <artifactId>commons-dbcp</artifactId> 
      <version>1.2.2</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-pool</groupId> 
      <artifactId>commons-pool</artifactId> 
      <version>1.6</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-core-asl</artifactId> 
      <version>1.9.9</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>1.9.9</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-asm</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-expression</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-digester</groupId> 
      <artifactId>commons-digester</artifactId> 
      <version>2.1</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-core</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>${org.slf4j-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.15</version> 
      <exclusions> 
       <exclusion> 
        <groupId>javax.mail</groupId> 
        <artifactId>mail</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>javax.jms</groupId> 
        <artifactId>jms</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jdmk</groupId> 
        <artifactId>jmxtools</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jmx</groupId> 
        <artifactId>jmxri</artifactId> 
       </exclusion> 
      </exclusions> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.7</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.ks.thirdparty</groupId> 
      <artifactId>jconn</artifactId> 
      <version>3</version> 
     </dependency> 
     <dependency> 
      <groupId>com.ks</groupId> 
      <artifactId>framework-common</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
     </dependency> 
     <dependency> 
      <groupId>com.ks.thirdparty</groupId> 
      <artifactId>ojdbc6_g</artifactId> 
      <version>1.0</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-eclipse-plugin</artifactId> 
       <version>2.9</version> 
       <configuration> 
        <additionalProjectnatures> 
         <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
        </additionalProjectnatures> 
        <additionalBuildcommands> 
         <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
        </additionalBuildcommands> 
        <downloadSources>true</downloadSources> 
        <downloadJavadocs>true</downloadJavadocs> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArgument>-Xlint:all</compilerArgument> 
        <showWarnings>true</showWarnings> 
        <showDeprecation>true</showDeprecation> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.2.1</version> 
       <configuration> 
        <mainClass>org.test.int1.Main</mainClass> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

回答

3

你可以试试这个:否则

<mirror> 
    <id>nexus-local</id> 
    <url>http://xxxxxx:8081/nexus/content/groups/public/</url> 
    <mirrorOf>external:*</mirrorOf> 
</mirror> 
<mirror> 
    <id>nexus.snapshots-local</id> 
    <url>http://xxxxx:8081/nexus/content/repositories/snapshots/</url> 
    <mirrorOf>snapshots</mirrorOf> 
</mirror> 

,有你检查你的Nexus,库是否正确下载。 您可能在nexus中存在网络问题,因此无法访问网络并下载插件和依赖关系。

如果您是使用代理,你需要配置它的Nexus:

管理 - >服务器 - >默认HTTP代理设置

enter image description here

+0

你知道我如何知道nexus是否无法访问网络?如果我尝试在中央存储库上“浏览远程”,我什么都看不到。 – Jared

+0

如果浏览远程无法正常工作,您的Nexus服务器无法访问中央回购站。在例如命令行并尝试ping中心并配置代理,如答案中所述。但不要将这些更改提供给settings.xml。 –

+0

有没有办法通过环境变量添加代理设置?它看起来像服务器不尊重“http_proxy”设置... –

0

要检查您的Nexus OSS安装可以到达网页,你可以登录管理员,然后打开Repositories(点击左侧的“知识库”),然后选择默认的Central知识库,然后在下部视图中选择Browse Remote选项卡,最后选择Refresh按钮。它应该会显示中央存储库中可用的所有组件(即,您的连接可以连接到Web)。 (注意:这个贡献应该是一个评论,但我不允许评论)。

0

我会摆脱您的设置中的代理部分第一。然后确保您可以从开发机器连接到Nexus实例。最后,确保您的Nexus可以通过在Nexus中配置代理设置来达到中心回购以及任何其他代理。

Nexus不会考虑settings.xml中的代理设置(因为它们是本地的,而不是你的Nexus服务器,这是没有意义的)。