软件编程
位置:首页>> 软件编程>> java编程>> 详解idea maven nexus 常见命令配置

详解idea maven nexus 常见命令配置

作者:dawang.  发布时间:2021-06-07 18:29:03 

标签:idea,maven,nexus,命令

maven 常见命令配置

maven常用命令


#创建项目 -D设置参数
mvn archetype:generate -DgroupId=cn.dwcode -DartifactId=dw.test.biz -Dversion=1.0.0
#创建项目 -B批处理模式构建项目
mvn archetype:generate -B -DgroupId=cn.dwcode -DartifactId=dw.test.biz -Dversion=1.0.0
mvn clean
mvn compile
mvn test
mvn package
mvn install
#-e详细异常 -U强制更新
mvn compile -e -U
#-P按配置打包 dev test pro 对于pom profiles
mvn package -P dev
#跳过测试 但是会编译test
mvn package -DskipTests
#跳过测试 并且会编译test
mvn package -Dmaven.test.skip=true

注意:如果命令执行失败需要制定jdk版本


<properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
   <java.version>1.8</java.version>
 </properties>

settings.xml

maven localRepository


<!--设置本地仓库 -->
<localRepository>D:\maven\repository</localRepository>

maven mirrors


<!--设置maven远程仓库-->
   <mirrors>
       <mirror>
           <id>aliyunmaven</id>
           <mirrorOf>*</mirrorOf>
           <name>阿里云公共仓库</name>
           <url>https://maven.aliyun.com/repository/public</url>
       </mirror>
   </mirrors>

maven profiles


<!--设置maven配置,选择设置不同的远程仓库-->
   <profiles>
       <!-- 可按profile设置私有仓库 -->
       <profile>
           <!-- id必须唯一 -->
           <id>nexus-repository-public</id>
           <repositories>
               <repository>
                   <!-- id必须唯一 -->
                   <id>public</id>
                   <!-- 仓库的url地址 -->
                   <url>http://192.168.72.130:8081/repository/maven-public</url>
                   <releases>
                       <enabled>true</enabled>
                   </releases>
                   <snapshots>
                       <enabled>true</enabled>
                   </snapshots>
               </repository>
           </repositories>
       </profile>
</profiles>

maven servers

设置maven deploy推送账号密码


<!--配置服务端的一些设置。一些设置如安全证书不应该和pom.xml一起分发。这种类型的信息应该存在于构建服务器上的settings.xml文件中。-->
   <servers>
       <!--设置maven deploy推送账号密码 -->
       <server>
           <!--id与distributionManagement中repository元素的id相匹配。-->
           <id>nexus-releases</id>
           <!--鉴权用户名。鉴权用户名和鉴权密码表示服务器认证所需要的登录名和密码。 -->
           <username>admin</username>
           <!--鉴权密码 。鉴权用户名和鉴权密码表示服务器认证所需要的登录名和密码。密码加密功能已被添加到2.1.0 +。详情请访问密码加密页面-->
           <password>123456</password>
       </server>
   </servers>

maven 完整配置


<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<!-- 默认的值是${user.home}/.m2/repository -->
   <localRepository>D:\maven\repository</localRepository>

<!-- 如果Maven要试图与用户交互来得到输入就设置为true,否则就设置为false,默认为true。 -->
   <interactiveMode>true</interactiveMode>

<!-- 如果Maven使用${user.home}/.m2/plugin-registry.xml来管理plugin的版本,就设置为true,默认为false。 -->
   <usePluginRegistry>false</usePluginRegistry>

<!-- 如果构建系统要在离线模式下工作,设置为true,默认为false。 如果构建服务器因为网络故障或者安全问题不能与远程仓库相连,那么这个设置是非常有用的。 -->
   <offline>false</offline>

<!--maven全局仓库 -->
   <mirrors>
       <!-- <mirror>
           <id>nexus-public</id>
           <mirrorOf>central</mirrorOf>
           <name>NexusLocal</name>
           <url>http://192.168.72.130:8081/repository/maven-public</url>
       </mirror> -->
       <mirror>
           <id>aliyunmaven</id>
           <mirrorOf>*</mirrorOf>
           <name>阿里云公共仓库</name>
           <url>https://maven.aliyun.com/repository/public</url>
       </mirror>
   </mirrors>

<!-- settings.xml中的profile是pom.xml中的profile的简洁形式。 它包含了激活(activation),仓库(repositories),插件仓库(pluginRepositories)和属性(properties)元素。
       profile元素仅包含这四个元素是因为他们涉及到整个的构建系统,而不是个别的POM配置。 如果settings中的profile被激活,那么它的值将重载POM或者profiles.xml中的任何相等ID的profiles。 -->
   <profiles>
       <!-- 可按profile设置私有仓库 -->
       <profile>
           <!-- id必须唯一 -->
           <id>nexus-repository-public</id>
           <repositories>
               <repository>
                   <!-- id必须唯一 -->
                   <id>public</id>
                   <!-- 仓库的url地址 -->
                   <url>http://192.168.72.130:8081/repository/maven-public</url>
                   <releases>
                       <enabled>true</enabled>
                   </releases>
                   <snapshots>
                       <enabled>true</enabled>
                   </snapshots>
               </repository>
           </repositories>
       </profile>
       <profile>
           <!-- id必须唯一 -->
           <id>aliyun-repository-public</id>
           <repositories>
               <repository>
                   <id>public</id>
                   <url>https://maven.aliyun.com/repository/public</url>
                   <releases>
                       <enabled>true</enabled>
                   </releases>
                   <snapshots>
                       <enabled>true</enabled>
                   </snapshots>
               </repository>
           </repositories>
       </profile>
   </profiles>
   <!-- activations是profile的关键,就像POM中的profiles,profile的能力在于它在特定情况下可以修改一些值。
       而这些情况是通过activation来指定的。 -->
   <!-- <activeProfiles/> -->

<!--配置服务端的一些设置。一些设置如安全证书不应该和pom.xml一起分发。这种类型的信息应该存在于构建服务器上的settings.xml文件中。-->
   <servers>
       <!--设置maven deploy推送账号密码 -->
       <server>
           <!--id与distributionManagement中repository元素的id相匹配。-->
           <id>nexus-releases</id>
           <!--鉴权用户名。鉴权用户名和鉴权密码表示服务器认证所需要的登录名和密码。 -->
           <username>admin</username>
           <!--鉴权密码 。鉴权用户名和鉴权密码表示服务器认证所需要的登录名和密码。密码加密功能已被添加到2.1.0 +。详情请访问密码加密页面-->
           <password>123456</password>
       </server>
   </servers>

</settings>

idea常见配置

idea maven 配置

详解idea maven nexus 常见命令配置

idea 刷新jar

详解idea maven nexus 常见命令配置

idea 跳过测试

详解idea maven nexus 常见命令配置

idea deploy配置

需要配置maven servers

pom.xml


<!--设置maven deploy仓库-->
   <distributionManagement>
       <repository>
           <id>nexus-releases</id>
           <url>http://192.168.72.130:8081/repository/maven-releases</url>
       </repository>
   </distributionManagement>

<build>
       <plugins>
           <!-- 要将源码放上去,需要加入这个插件 -->
           <plugin>
               <artifactId>maven-source-plugin</artifactId>
               <version>3.2.1</version>
               <executions>
                   <execution>
                       <goals>
                           <goal>jar</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
       </plugins>
   </build>

详解idea maven nexus 常见命令配置

idea profile选择

详解idea maven nexus 常见命令配置

idea 获取jar循序

详解idea maven nexus 常见命令配置

nexus 常见配置

nexus部署


#创建nexus数据目录
mkdir -p /usr/local/work/nexus-data && chown -R 200 /usr/local/work/nexus-data

#运行模型
docker run -d \
-p 8081:8081 \
--name nexus \
-v /usr/local/work/nexus-data:/nexus-data \
sonatype/nexus3:3.19.1

#获取初始密码
echo `docker exec nexus cat /nexus-data/admin.password`

登录:http://127.0.0.1:8081/

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yqXWZGBw-1618752330380)(idea_maven_nexus常见命令配置.assets\image-20210418211114096.png)]

nexus添加阿里云代理

阿里云配置:https://maven.aliyun.com/mvn/guide

详解idea maven nexus 常见命令配置

详解idea maven nexus 常见命令配置

详解idea maven nexus 常见命令配置

详解idea maven nexus 常见命令配置

nexus修改可更新

详解idea maven nexus 常见命令配置

来源:https://blog.csdn.net/tiancxz/article/details/115836928

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com