nexus常用维护

一 环境信息

二 常用维护

2.1 手工上传jar到snap-shot 库

2.1.1 官网参考

官网参考 https://support.sonatype.com/hc/en-us/articles/115006744008-How-can-I-programmatically-upload-files-into-Nexus-3-

无pom 文件

mvn deploy:deploy-file -DgroupId=com.somecompany -DartifactId=project -Dversion=1.0.0 -DgeneratePom=true -Dpackaging=jar -DrepositoryId=nexus -Durl=http://localhost:8081/repository/maven-releases -Dfile=target/project-1.0.0.jar

有pom 文件

mvn deploy:deploy-file -DgeneratePom=false -DrepositoryId=nexus -Durl=http://localhost:8081/repository/maven-releases -DpomFile=pom.xml -Dfile=target/project-1.0.0.jar

参数说明:
DgroupId 该jar groupid
DartifactId 该jar artifactId
Dversion 该jar 版本
DrepositoryId settings.xml 文件里配置的server

2.1.2 实际用例

2.1.2.1 settings.xml 配置

maven-snapshots对应 DrepositoryId

  <servers>
    <server>
      <id>maven-snapshots</id>
      <username>admin</username>
      <password>密码</password>
    </server>
  </servers>

  <profiles>

   <profile>
      <id>nexus</id>
      <repositories>
         <repository>
          <id>maven-snapshots</id>
          <name>maven-snapshots</name>
          <url>http://XXXXXX.com/repository/maven-snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>maven-snapshots</id>
          <name>maven-snapshots</name>
          <url>http://XXXXXX.com/repository/maven-snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
2.1.2.2 实际命令
mvn deploy:deploy-file -DgroupId=com.XXXX.XXXX -DartifactId=XXXX-lib -Dversion=3.1.4-SNAPSHOT -Dpackaging=jar -Dfile=XXXX-lib-3.1.4-SNAPSHOT.jar -DpomFile=XXXX-lib-3.1.4-SNAPSHOT.pom -Durl=http://XXXX.XXXX.com/repository/maven-snapshots/ -DrepositoryId=maven-snapshots

经验:一般需要手工上传snap-shot 库,肯定是丢失了原jar,也找不到原始jar 关联的代码,无法重新发版,
有原始pom 文件一定要使用有pom文件命令,这样会把jar 之间的关系带进去

你可能感兴趣的:(java,devops,运维)