详解idea maven nexus 常见命令配置
作者:dawang. 时间:2021-06-07 18:29:03
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 刷新jar
idea 跳过测试
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 profile选择
idea 获取jar循序
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
nexus修改可更新
来源:https://blog.csdn.net/tiancxz/article/details/115836928
标签:idea,maven,nexus,命令
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java中Function的使用及说明
2023-08-12 03:04:29
![](https://img.aspxhome.com/file/2023/5/58025_0s.png)
servlet异步请求的实现
2023-07-14 17:11:38
![](https://img.aspxhome.com/file/2023/4/57724_0s.png)
SpringCloud Feign配置应用详细介绍
2023-07-14 04:23:03
![](https://img.aspxhome.com/file/2023/7/57497_0s.png)
使用Spring Security OAuth2实现单点登录
2023-08-13 01:44:34
java IO流文件的读写具体实例
2023-08-21 04:44:34
![](https://img.aspxhome.com/file/2023/2/58072_0s.jpg)
Android使用phonegap从相册里面获取照片(代码分享)
2023-07-24 18:53:03
Java字符串拼接新方法 StringJoiner用法详解
2022-06-16 13:02:13
Java8内存模型PermGen Metaspace实例解析
2023-11-25 10:53:36
![](https://img.aspxhome.com/file/2023/8/59968_0s.jpg)
深入理解Java注解类型(@Annotation)
2022-11-14 17:28:42
![](https://img.aspxhome.com/file/2023/8/60788_0s.png)
Java内存模型(JMM)及happens-before原理
2023-11-25 00:41:05
![](https://img.aspxhome.com/file/2023/2/59972_0s.png)
Java应用多机器部署解决大量定时任务问题
2023-10-28 17:07:17
![](https://img.aspxhome.com/file/2023/1/58691_0s.png)
Spring Cloud Eureka 服务上下线监控的实现
2022-02-18 21:06:15
Dubbo实现分布式日志链路追踪
2023-08-23 21:00:54
![](https://img.aspxhome.com/file/2023/2/58292_0s.png)
Android实现图片设置圆角形式
2023-07-29 16:37:32
![](https://img.aspxhome.com/file/2023/6/85456_0s.jpg)
Spring @Bean注解的使用场景与案例实现
2023-11-20 04:44:22
JAVA布局管理器与面板组合代码实例
2022-04-23 15:48:55
![](https://img.aspxhome.com/file/2023/4/60534_0s.png)
C#如何通过匿名类直接使用访问JSON数据详解
2023-07-20 12:31:53
![](https://img.aspxhome.com/file/2023/7/67057_0s.jpg)
java设计模式学习之工厂方法模式
2023-10-12 17:19:04
![](https://img.aspxhome.com/file/2023/7/58607_0s.jpg)
JAVA如何按字节截取字符串
2023-11-25 13:31:41
SpringBoot2之PUT请求接收不了参数的解决方案
2023-08-23 01:32:07
![](https://img.aspxhome.com/file/2023/2/58202_0s.png)