[英]How to change Maven build path for repository when building project in command line
I am building a .war
file for my Maven project after checking out the project from SVN using: 在使用以下命令从SVN中签出项目后,我正在为Maven项目构建
.war
文件:
mvn clean package
However, it appears that Maven search for the libraries (maven dependencies) based on the current location of the project folder. 但是,看来Maven会根据项目文件夹的当前位置搜索库(Maven依赖项)。 (Underlined in yellow as below image).
(下划线显示为黄色,如下图所示)。 The project was placed in
D:\\DCA
该项目被放置在
D:\\DCA
I want mvn
to search for the libraries from my .m2
repository folder instead of D:\\DCA\\..
. 我希望
mvn
从.m2
存储库文件夹而不是D:\\DCA\\..
搜索库。 I believe there is a config file or settings file somewhere which allows me to change the location of the repository for project building. 我相信某个地方有一个配置文件或设置文件,可以让我更改用于项目构建的存储库的位置。
So my question is : Where/how can I change the path as underlined in yellow in the above image? 所以我的问题是 :在上图中,如何/如何更改黄色底线所示的路径?
After you have downloaded the maven, follow given simple steps to change maven local repository location to some other path. 下载了Maven之后,请按照给定的简单步骤将Maven本地存储库位置更改为其他路径。
Save the file. 保存文件。 http://maven.apache.org/xsd/settings-1.0.0.xsd">
http://maven.apache.org/xsd/settings-1.0.0.xsd“>
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository --> <localRepository>E:/devsetup/M2</localRepository> </settings>
============================================== ==============================================
Start maven with -X option (debug) and examine the beginning of the output. 使用-X选项(调试)启动maven并检查输出的开始。
There should be something like this 应该有这样的东西
[INFO] Error stacktraces are turned on. [INFO]错误堆栈跟踪已打开。
[DEBUG] Reading global settings from c:....\\apache-maven-3.0.3\\conf\\settings.xml [DEBUG]从c:.... \\ apache-maven-3.0.3 \\ conf \\ settings.xml读取全局设置
[DEBUG] Reading user settings from c:.....m2\\settings.xml [DEBUG]从c:..... m2 \\ settings.xml读取用户设置
[DEBUG] Using local repository at C:....\\repository [DEBUG]在C:.... \\ repository中使用本地存储库
Here you can see from where Maven is picking up the setting. 在这里,您可以从Maven那里获取设置。
==================================================== ================================================== ==
If you want to specify your own settings.xml then 如果要指定自己的settings.xml,则
mvn --settings customSetting.xml clean install
or 要么
mvn -s customSetting.xml clean install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.