详解idea maven nexus 常见命令配置

 更新时间:2021年04月20日 09:49:58   作者:dawang.  
这篇文章主要介绍了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 刷新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修改可更新

在这里插入图片描述

到此这篇关于idea maven nexus 常见命令配置的文章就介绍到这了,更多相关idea maven nexus命令配置内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Spring Security单项目权限设计过程解析

    Spring Security单项目权限设计过程解析

    这篇文章主要介绍了Spring Security单项目权限设计过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-11-11
  • idea更改默认缓存位置的步骤详解

    idea更改默认缓存位置的步骤详解

    在idea使用中,会产生大量的缓存,一般默认存放在C盘里面,会加大C盘的储存负担,如果C盘足够大,可以不考虑更改idea的缓存位置,所以本文小编给如何更改idea默认缓存位置,文中通过图文结合介绍的非常详细,需要的朋友可以参考下
    2023-12-12
  • java使用Base64编码实例

    java使用Base64编码实例

    这篇文章主要介绍了java使用Base64编码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-03-03
  • 浅谈在eclipse中如何修改svn的用户名和密码

    浅谈在eclipse中如何修改svn的用户名和密码

    这篇文章主要介绍了在eclipse中如何修改svn的用户名和密码的方法,在eclipse中经常用svn进行代码版本控制,提交或更新代码的时候需要我们输入用户名和密码。对此感兴趣的话可以来了解一下
    2020-07-07
  • Spring注解驱动扩展原理BeanFactoryPostProcessor

    Spring注解驱动扩展原理BeanFactoryPostProcessor

    这篇文章主要介绍了Spring注解驱动扩展原理BeanFactoryPostProcessor,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-03-03
  • Servlet+MyBatis项目转Spring Cloud微服务,多数据源配置修改建议

    Servlet+MyBatis项目转Spring Cloud微服务,多数据源配置修改建议

    今天小编就为大家分享一篇关于Servlet+MyBatis项目转Spring Cloud微服务,多数据源配置修改建议,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
    2019-01-01
  • 基于springboot实现redis分布式锁的方法

    基于springboot实现redis分布式锁的方法

    这篇文章主要介绍了基于springboot实现redis分布式锁的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-11-11
  • Java集合继承体系详解

    Java集合继承体系详解

    这篇文章主要为大家详细介绍了Java集合继承体系,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-11-11
  • 解读@NoArgsConstructor,@AllArgsConstructor,@RequiredArgsConstructor的区别及在springboot常用地方

    解读@NoArgsConstructor,@AllArgsConstructor,@RequiredArgsConstr

    这篇文章主要介绍了解读@NoArgsConstructor,@AllArgsConstructor,@RequiredArgsConstructor的区别及在springboot常用地方,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2023-12-12
  • Java四种遍历Map的方法

    Java四种遍历Map的方法

    今天小编就为大家分享一篇关于Java四种遍历Map的方法,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
    2019-01-01

最新评论