简体   繁体   English

在命令行中构建项目时如何更改存储库的Maven构建路径

[英]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本地存储库位置更改为其他路径。

  • Navigate to path {M2_HOME}\\conf\\ where M2_HOME is maven installation folder. 导航到路径{M2_HOME} \\ conf \\,其中M2_HOME是maven安装文件夹。
  • Open file settings.xml in edit mode in some text editor. 在某些文本编辑器中以编辑方式打开文件settings.xml。
  • Find the tag Update the desired path in the value of this tag. 查找标签在此标签的值中更新所需的路径。
  • 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.

相关问题 构建项目时如何通过Maven更改hibernate.cfg.xml文件路径? - How to change hibernate.cfg.xml file path through maven when building project? 如何在不使用第三个多模块 maven 项目的情况下自动从命令行构建主 Maven 项目之前构建项目依赖关系? - How to build project dependency before building main Maven project from command line automatically without using 3rd multi module maven project? 如何在使用Maven构建jar时添加命令行参数 - How to add command line arguments when building jar with Maven Maven:如何从命令行更改目标目录的路径? - Maven: How to change path to target directory from command line? 在 Maven 中,在构建主项目时,如何构建作为依赖项添加到主项目中的依赖项目? - In Maven How to build the dependent projects that are added as the dependencies in the main project when building the main project? DTD在Eclipse中的项目目标路径中显示,但在通过Maven命令行使用时不显示 - DTDs show up in project target path in Eclipse but not when using via Maven command line Maven命令行中的Java Build Path模拟是什么? - What is the Java Build Path analog in the Maven command line? 安装到本地存储库并部署到远程存储库时,如何在Maven中构建WAR项目并提供自定义名称 - How to build a WAR project in Maven giving a customized name when installed to local repository and deployed to remote repositories 从命令行构建时出现Maven错误 - Inconstant Maven error when building from command line 如何阻止 Maven 将项目构建 JAR 安装到本地存储库 - How to stop Maven from installing project build JAR to local repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM