---
title: "Eclipse&Maven&Nexus"
author: "adapterofcoms"
date: "2015-06-26T22:34:18Z"
tags: []
categories: ["Web前端"]
slug: "eclipse-maven-nexus"
draft: false
lastmod: "2019-04-28T17:02:03Z"
id: 2169138
url: "https://adapterofcoms.iteye.com/blog/2169138"
---

Nexus2:  
nexus\\bin\\jsw\\windows-x86-64\\install-nexus   #install it to Wndows Service.

nexus3 oss:  
https://www.sonatype.com/download-oss-sonatype  
http://blog.csdn.net/rekadowney/article/details/52492587  
http://blog.csdn.net/qq250782929/article/details/51605965

 

nexus-default.properties

nexus /install /uninstall /run

 

目前较快的maven镜像：

http://central.maven.org/maven2/ http://repo1.maven.org/maven2/  #中有.index目录：nexus-maven-repository-index.gz nexus-maven-repository-index.properties

快速的获取nexus-maven-repository-index.gz和nexus-maven-repository-index.properties的方法：先下载这2个文件，再copy到Tomcat ROOT 构建maven2/.index目录(win下尝试在cmd下mkdir)，并修改到80端口。

修改 Remote Storage Location ： http://127.0.0.1/maven2

update index , eclipse rebuild index

右键central repository

switch Allow Proxy / Block Proxy

**如果setting.xml中指定的中央仓库为nexus/content/groups/public,在nexus中就应对相应的Public Repositories进行repair index, 如果只对nexus中的Central做repair index,那么eclipse中的maven index不能更新。**

**index updating:**  
**首先对nexus中setting.xml中指定的中央仓库进行update index,然后对eclipse中的Global Repositories中的中央仓库Rebuild Index即可。**  
 

#ref--&gt; http://blog.163.com/benbenfafa\_88/blog/static/6493016220130451915187/

1.在Maven setting.xml文件中配置Nexus仓库,profile mirror  ?  
**本地仓库 &gt;profile &gt; pom中的repository &gt; mirror** 但是如果**&lt;mirrorOf&gt;\*&lt;/mirrorOf&gt;**，maven会忽略掉其他设置的各种类型仓库，只在mirror里面找。  
**中央仓库(central,Central Repository), 中央仓库是maven核心自带的远程仓库**,默认url在 MAVEN\_HOME/lib/maven-model-builder-3.X.jar,  
**org/apache/maven/model/pom-4.0.0.xml**  --&gt;  
&lt;repositories&gt;  
    &lt;repository&gt;  
      &lt;id&gt;**central**&lt;/id&gt;  
      &lt;name&gt;**Central Repository**&lt;/name&gt;  
      &lt;url&gt;**https://repo.maven.apache.org/maven2**&lt;/url&gt;  
      &lt;layout&gt;default&lt;/layout&gt;  
      &lt;snapshots&gt;  
        &lt;enabled&gt;false&lt;/enabled&gt;  
      &lt;/snapshots&gt;  
    &lt;/repository&gt;  
  &lt;/repositories&gt;

  &lt;pluginRepositories&gt;  
    &lt;pluginRepository&gt;  
      &lt;id&gt;central&lt;/id&gt;  
      &lt;name&gt;Central Repository&lt;/name&gt;  
      &lt;url&gt;https://repo.maven.apache.org/maven2&lt;/url&gt;  
      &lt;layout&gt;default&lt;/layout&gt;  
      &lt;snapshots&gt;  
        &lt;enabled&gt;false&lt;/enabled&gt;  
      &lt;/snapshots&gt;  
      &lt;releases&gt;  
        &lt;updatePolicy&gt;never&lt;/updatePolicy&gt;  
      &lt;/releases&gt;  
    &lt;/pluginRepository&gt;  
  &lt;/pluginRepositories&gt;  
  &lt;build&gt;  
    &lt;directory&gt;**${project.basedir}**/target&lt;/directory&gt;  
    。。。。。。

e.g:【&lt;**dependency**&gt;  
    &lt;groupId&gt;xxx&lt;/groupId&gt;  
    &lt;artifactId&gt;xxx&lt;/artifactId&gt;  
    &lt;version&gt;1.0&lt;/version&gt;  
    **&lt;scope&gt;system&lt;/scope&gt;**  
    &lt;**systemPath**&gt;**${project.basedir}**/lib/xxx.jar&lt;/**systemPath**&gt;  
&lt;/**dependency**&gt;】  
在setting.xml中：  
&lt;mirror&gt;   
        &lt;id&gt;nexus&lt;/id&gt;   
        &lt;name&gt;Nexus Public Mirror&lt;/name&gt;   
        &lt;url&gt;http://localhost:8081/nexus/content/groups/public&lt;/url&gt;   
        **&lt;mirrorOf&gt;central&lt;/mirrorOf&gt;&lt;!--override the default central repository\[https://repo.maven.apache.org/maven2]--&gt;**  
    &lt;/mirror&gt;

**project's pom.xml中的repositories只是补充central repository而非替代！**

 

2.Hosted upload ?   部署构件到Nexus仓库?

 &lt;**distributionManagement**&gt;  
    &lt;**repository**&gt;  
        &lt;id&gt;releases&lt;/id&gt;  
        &lt;name&gt;Releases&lt;/name&gt;  
        &lt;url&gt;http://192.168.0.21:8081/nexus/content/repositories/releases&lt;/url&gt;  
    &lt;/**repository**&gt;  
    &lt;**snapshotRepository**&gt;  
        &lt;id&gt;snapshots&lt;/id&gt;  
        &lt;name&gt;Snapshots&lt;/name&gt;  
        &lt;url&gt;http://192.168.0.21:8081/nexus/content/repositories/snapshots&lt;/url&gt;  
    &lt;/**snapshotRepository**&gt;  
&lt;/**distributionManagement**&gt;

Maven:

 M2\_HOME

 

 

 

 update project---&gt;.lastUpdated  
 针对私服与中央仓库或第三方仓库之间网络传输问题  
 Browser Storage---&gt;找到相应的package 先update index,再expire cache

 

Eclipse:

 Maven Preferences--&gt;installations: MAVEN\_HOME , User Settings: MAVEN\_HOME  
pom.xml --&gt;JDK VERSION CFG :  
&lt;build&gt;  
    &lt;finalName&gt;project name&lt;/finalName&gt;  
    &lt;plugins&gt;   
      &lt;plugin&gt;   
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;   
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;   
        &lt;configuration&gt;   
          &lt;source&gt;1.7&lt;/source&gt;   
          &lt;target&gt;1.7&lt;/target&gt;  
          **&lt;compilerId&gt;eclipse&lt;/compilerId&gt; 默认是javac**  
        &lt;/configuration&gt;  
        &lt;dependencies&gt;   
                        &lt;dependency&gt;   
                            &lt;groupId&gt;org.codehaus.plexus&lt;/groupId&gt;   
                            &lt;artifactId&gt;plexus-compiler-**eclipse**&lt;/artifactId&gt;  使用eclipse JDT,不兼容的类型，推断类型不符合上限  
                            &lt;version&gt;2.6&lt;/version&gt;   
                        &lt;/dependency&gt;   
           &lt;/dependencies&gt;   
      &lt;/plugin&gt;   
    &lt;/plugins&gt;  
  &lt;/build&gt;

 **Eclipse IDE debug keyboard shortcuts---&gt; F5(进入函数)/F6(下一行)/F7(跳出当前函数)/F8(下一断点)**