maven_nexus 私服加项目

1、安装maven
下载 mavean安装包
解压文件
配置环境变量:MAVEN_HOME:{解压后的根目录}
验证安装是否成功:cmd dos命令中  mvn -version 有显示则成功
mvn help:system,自动下载maven基础插件
2、安装nexus
下载 nexus,下载war版本,放在tomcat中运行tomcat,需要注意版本,与所使用的tomcat匹配
http://127.0.0.1:8081/nexus login in  admin/admin123
选择respositories查看仓库信息
3、配置maven使用nexus
maven目录下,查看conf/settings.xml中

<localRepository>D:/PRO</localRepository>

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

<profiles>
  <profile>
    <id>dev</id>
    <repositories>
      <repository>
        <id>local-nexus</id>
        <url>http://127.0.0.1:8081/nexus/content/groups/public</url>
        <releases>
           <enabled>true</enabled>
        </releases>
        <snapshots>
           <enabled>true</enabled>
        </snapshots>
      </repository>
    </repositories>
  </profile>
</profiles>

<activeProfiles>
  <activeProfile>dev<activeProfile>
</activeProfiles>


4、maven项目中使用nexus
pom.xml

<!--配置使用私服-->
<distributionManagement>
  <repository>
    <id>user-release</id>
    <name>my project release</name>
    <url>http://localhost:8081/nexus/content/repostitories/releases/</url>
  </repository>
  <snapshotRepository>
    <id>user-snapshots</id>
    <name>my project release</name>
    <url>http://localhost:8081/nexus/content/repostitories/snapshots/</url>
  </snapshotRepository>
</distributionManagement>
<!--配置需要使用的架包-->
<dependencies>
   <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</arcifactId>
     <version>1.2.16</version>
   </dependency>
</dependencies>

项目 build path,库中,添加maven dependencies

你可能感兴趣的:(maven)