• Window下部署Maven Nexus


    Nexus下载地址:https://www.sonatype.com/download-oss-sonatype

    选择相应的版本下载后,本人下载的是nexus-2.12.0-01-bundle.zip版本。nexus默认是和jetty集成的,如果要在Tomcat环境下使用,则按照如下步骤进行配置即可:

    1,解压文件后后得到两个文件夹,[nexus-2.12.0-01]及[sonatype-work],[nexus-2.12.0-01]文件夹看到他的结构类似于Tomcat服务器。

    将这两个文件夹复制到一个目录下,可以不用在Tomcat的webapps目录下也行。本人是在webapps下面创建了一个Nexus的文件夹,并将这两个文件复制到里面,如:F:Tomcat8apache-tomcat-8.5.9webappsNexus。

    2.把nexus-2.12.0-01lib文件夹下面的除了javax.servlet*.jar及jetty*jar的所有jar包文件复制到nexus-2.12.0-01 exusWEB-INFlib下面。

    3.修改nexus-2.12.0-01 exusWEB-INFclasses exus.properties文件修改:nexus-work=F:/Tomcat8/apache-tomcat-8.5.9/webapps/Nexus/sonatype-work/nexus,注意斜杆的方向。

    4.修改Tomcat的server.xml文件,在Host节点内添加Context节点,修改后如下:

    <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log" suffix=".txt"
                   pattern="%h %l %u %t "%r" %s %b" />
    
    	    <Context docBase="F:Tomcat8apache-tomcat-8.5.9webappsNexus
    exus-2.12.0-01
    exus" path="/nexus" reloadable="true"/>
    
          </Host>
    

    启动Tomcat,在浏览器打开地址http://localhost/nexus,我用的是80端口,成功了。

     5.修改本地的Maven配置文件内容

    找到用户的.m2/setting.xml文件,也可以在Eclipse的Preferences->Maven->User Settings->User Settings内找到。

    打开此文件,在此文件内添加本地的Maven仓库目录,如:

    <localRepository>F:MavenMavenRepository</localRepository>

    添加Maven镜像仓库位置:

    <mirror>
    	<id>nexus</id>
    	<mirrorOf>*</mirrorOf>
    	<url>http://localhost/nexus/content/groups/public/</url>
     </mirror>
    <mirror>
    	<id>snapshots</id>
    	<mirrorOf>snapshots</mirrorOf>
    	<url>http://localhost/nexus/content/repositories/snapshots/</url>
    </mirror>
    

    配置Profile及激活Profile

    <profile>   
          <id>development</id>   
          <repositories>   
                <repository>   
                    <id>central</id>                                      
                    <url>http://localhost/nexus/content/groups/public/</url>        
                    <releases>   
                        <enabled>true</enabled>   
                    </releases>   
                    <snapshots>   
                        <enabled>true</enabled>   
                    </snapshots>   
                </repository>   
            </repositories>      
             <pluginRepositories>   
                <pluginRepository>   
                  <id>central</id>   
                  <url>http://localhost/nexus/content/groups/public/</url>
                  <releases>   
                    <enabled>true</enabled>   
                  </releases>   
                  <snapshots>   
                    <enabled>false</enabled>   
                  </snapshots>   
                </pluginRepository>   
            </pluginRepositories>   
        </profile>  
    
      </profiles>
      <activeProfiles>
        <activeProfile>development</activeProfile>
      </activeProfiles>
    

    添加认证信息,填写正确的用户名密码

    <server>
          <id>nexus-releases</id>
          <username>admin</username>
          <password>admin</password>
        </server>
    	<server>
          <id>nexus-snapshots</id>
          <username>admin</username>
          <password>admin</password>
     </server>
    

      

    6.构建项目并部署到Nexus仓库,修改pom文件(自动部署),这里到底是部署到release仓库还是snapshots,具体还要看项目的version的后缀是snapshots还是release。

    <!-- 自动部署构件到Nexus仓库 -->
    	<distributionManagement>
    		<repository>
    			<id>nexus-releases</id>
    			<url>http://localhost/nexus/content/repositories/releases/</url>
    		</repository>
    		<snapshotRepository>
    			<id>nexus-snapshots</id>
    			<url>http://localhost/nexus/content/repositories/snapshots/</url>
    		</snapshotRepository>
    	</distributionManagement>
    

    执行命令:mvn clean deploy  部署到Nexus仓库内。

    最终部署到Nexus仓库效果如下,项目的version为0.0.1-RELEASE

  • 相关阅读:
    用javascript获取屏幕高度和宽度等信息
    Delphi程序启动参数的读取
    在CSS中使用javascript运算表达式
    How to check an Internet connection
    CheckMenuItem Function in Delphi
    在delphi中添加一个菜单项到Windows的系统菜单
    Delphi中直接将DataSet中的数据写入Excel文件
    带有TClientDataSet的delphi应用程序在发布时应注意的问题
    Delphi下一个封装较为完整的DBGrid>Excel类
    how to advertent to connect to internet?
  • 原文地址:https://www.cnblogs.com/foxting/p/6852081.html
Copyright © 2020-2023  润新知