场景

某天我在本地修改了某个子项目的代码,并进行了打包:mvn clean install -DskipTests,接着我运行父项目却发现自己刚刚的改动并没有生效,或者说,我刚刚打包好的子项目变回了打包前的代码。

通过cmd的输出我发现在运行父项目的时候,自动下载更新了远程依赖库的子项目,因此将我本地打包修改好的子项目依赖给更新成了远程库的,这就是为什么我明明打包了本地修改好的子项目代码却没有在父项目生效的原因。

解决方法

在maven的配置文件settings.xml里有个offline节点,可以通过该节点来控制是否在编译项目时自动下载远程依赖库的最新版本。注意,如果你同时有多个配置文件,必须要修改~/.m2下的settings.xml才有效。

<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->

将配置文件里的offline节点的注释去掉并改为true,或者自己加一个:

<offline>true</offline>

当然,这样做只是为了方便本地测试而已,如果测试完毕不需要再改代码了,最好还是将该节点改为false,否则你如果在pom文件里引入了本地仓库所没有的依赖时,是不会自动帮你从远处库下载依赖的!!

相关的问题

offline可能会导致启动mvn项目时报错:

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Cannot access spring-releases (https://repo.spring.io/libs-release) in offline mode and the artifact org.springframework.boot:spring-boot-loader-tools:jar:2.0.5.RELEASE has not been downloaded from it before.

因为offline mode导致无法从线上仓库下载依赖,将offline的值改为false就行了。

Maven - settings.xml里的offline节点的作用的更多相关文章

  1. Maven settings.xml配置(指定本地仓库、阿里云镜像设置)

    转: 详解Maven settings.xml配置(指定本地仓库.阿里云镜像设置) 更新时间:2018年12月18日 11:14:45   作者:AmaniZ   我要评论   一.settings. ...

  2. 基于nexus私服配置项目pom.xml和maven settings.xml文件

    备注:搭建nexus私服请参考上一篇文章基于Docker搭建Maven私服Nexus,Nexus详解 一:将jar发送到nexus私服务器 1.pom.xml文件添加配置 pom.xml文件中的这个版 ...

  3. maven settings.xml详解

    setting.xml配置文件 http://blog.csdn.net/u012152619/article/details/51485152 maven的配置文件settings.xml存在于两个 ...

  4. 学习笔记——Maven settings.xml 配置详解

    文件存放位置 全局配置: ${M2_HOME}/conf/settings.xml 用户配置: ${user.home}/.m2/settings.xml note:用户配置优先于全局配置.${use ...

  5. Maven settings.xml配置解读

    本文对${maven.home}\conf\settings.xml的官方文档作个简单的解读,请确保自己的maven环境安装成功,具体安装流程详见Maven安装 第一步:看settings.xml的内 ...

  6. Maven——settings.xml配置

    settings.xml配置 原文 <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed ...

  7. 架构实战项目心得(四)(补):Maven settings.xml的所有标签详解

    文章内容较长,各位看客可以根据自己需要CTRL+F 直接定位到自己需要了解的地方哦~ <?xmlversion="1.0" encoding="UTF-8" ...

  8. maven - settings.xml文件详解

    Settings.xml配置文件详解 maven默认的settings.xml是一个包含注释和例子的模板,可以快速的修改settings.xml文件 maven安装后不会在用户目录下自动生成setti ...

  9. maven settings.xml 阿里云

    <?xml version="1.0" encoding="UTF-8"?> <!--Licensed to the Apache Softw ...

随机推荐

  1. linux环境下远程访问ftp

    sftp ftpuser@127.0.0.1 使用sftp命令 ftpuser是用户名 127.0.0.1是目标ip 亲测好使.

  2. windows定时计划备份MySql

    使用 MySql 的 mysqldump 将数据库文件备份成 sql 文件. Windows下备份 本地的数据库环境 MySql 安装环境:C:\MySql 数据库名称:bbs root root 数 ...

  3. JavaWeb浏览器传值乱码

    在Java服务接口调用中,可能会出现乱码,如下图所示: 这是由编码不一致而致的乱码,可转,如下: name = new String(name.getBytes("ISO-8859-1&qu ...

  4. Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution —— 异或

    题目链接:http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible so ...

  5. Object.prototype.constructor

    Returns a reference to the Object function that created the instance's prototype. 注意这个属性的值是函数本省的引用,而 ...

  6. 我的CSDN博客

    从csdn搬过来的: csdn地址:http://blog.csdn.net/WR_technology

  7. 多线程之:lock和synchronized的区别

    多次思考过这个问题,都没有形成理论,今天有时间了,我把他总结出来,希望对大家有所帮助 1.ReentrantLock 拥有Synchronized相同的并发性和内存语义,此外还多了 锁投票,定时锁等候 ...

  8. hdu 3932 Groundhog Build Home —— 模拟退火

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3932 找一个位置使距离最远的点的距离最小: 上模拟退火: 每次向距离最远的点移动,注意判断一下距离最远的点 ...

  9. android自动化测试之uiautomator

    1.通过monkeyrunner.bat   monkey_record.py启动MonkeyRecorder进行拿到各个控件的坐标(要连上手机才可以启动) 2.也可以通过uiautomatorvie ...

  10. struts2 ValueStack的set方法与setValue方法的区别

    struts2中 ValueStack的set方法与setValue方法的区别呢? 示例代码: ActionContext.getContext().getValueStack().setValue( ...