[英]Why maven settings.xml file is not there?
I installed maven plugin for eclipse and was able to use it only in eclipse.我为 eclipse 安装了 maven 插件,并且只能在 eclipse 中使用它。 I want to be able to run maven commands from terminal so installed maven as explained in the below link:
我希望能够从终端运行 maven 命令,因此安装了 maven,如以下链接中所述:
http://www.mkyong.com/maven/how-to-install-maven-in-ubuntu/ http://www.mkyong.com/maven/how-to-install-maven-in-ubuntu/
My questions are我的问题是
settings.xml
in this path /home/raki/.m2/
-- What should I do for this?/home/raki/.m2/
路径中找不到settings.xml
-- 我该怎么办?settings.xml
is not required (and thus not autocreated in ~/.m2 folder) unless you want to change the default settings. settings.xml
不是必需的(因此不会在 ~/.m2 文件夹中自动创建),除非您想更改默认设置。
Standalone maven and the maven in eclipse will use the same local repository (~/.m2 folder).独立的 maven 和 eclipse 中的 maven 将使用相同的本地存储库(~/.m2 文件夹)。 This means if some artifacts/dependencies are downloaded by standalone maven, it will not be again downloaded by maven in eclipse.
这意味着如果一些工件/依赖项是由独立的 Maven 下载的,它就不会被 Eclipse 中的 Maven 再次下载。
Based on the version of Eclipse that you use, you may have different maven version in eclipse compared to the standalone.根据您使用的 Eclipse 版本,与独立版本相比,Eclipse 中的 Maven 版本可能不同。 It should not matter in most cases.
在大多数情况下应该无关紧要。
Installation of Maven doesn't create the settings.xml
file. Maven 的安装不会创建
settings.xml
文件。 You have to create it on your own.您必须自己创建它。 Just put it in your
.m2
directory where you expected it, see http://maven.apache.org/settings.html for reference.只需将它放在您期望的
.m2
目录中,请参阅http://maven.apache.org/settings.html以供参考。 The m2eclipse plugin will use the same settings file as the command line. m2eclipse 插件将使用与命令行相同的设置文件。
As per the maven's documentation, there are two possible settings.xml locations根据 Maven 的文档,有两个可能的 settings.xml 位置
One is the global maven's repo (Your initial download and subsequent unzipped files from apache maven) $M2_HOME/conf/settings.xml一个是全局 maven 的 repo(您的初始下载和随后从 apache maven 解压缩的文件)$M2_HOME/conf/settings.xml
And the second is the user created one (Your local copy) ${user.home}/.m2/settings.xml第二个是用户创建的一个(您的本地副本)${user.home}/.m2/settings.xml
The local copy takes precedence over the global copy in terms of settings information.就设置信息而言,本地副本优先于全局副本。 But it is said that they both get merged during "runtime".
但据说它们都在“运行时”期间合并。 If you need to have your local copy of the settings.xml, simply copy from the global copy and paste in your .m2 folder and adjust the details as needed
如果您需要拥有 settings.xml 的本地副本,只需从全局副本中复制并粘贴到您的 .m2 文件夹中,然后根据需要调整详细信息
The settings.xml
file is not created by itself, you need to manually create it. settings.xml
文件不是自己创建的,需要手动创建。 Here is a sample:这是一个示例:
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
I also underwent the same issue as Maven doesn't create the settings.xml
file under .m2
folder.我也遇到了同样的问题,因为 Maven 没有在
.m2
文件夹下创建settings.xml
文件。 What I did was the following and it works smoothly without any issues.我所做的是以下操作,它运行顺利,没有任何问题。
Go to the location where you maven was unzipped .转到maven 解压缩的位置。
Direct to following path,直接到以下路径,
\\apache-maven-3.0.4\\conf\\
and copy the settings.xml
file and paste it inside your .m2
folder. \\apache-maven-3.0.4\\conf\\
并复制settings.xml
文件并将其粘贴到您的.m2
文件夹中。
Now create a maven project.现在创建一个 Maven 项目。
You can verify where your Setting.xml
is by pressing shortcut Ctrl+3
, you will see Quick Access
on top right side of Eclipse
, then search setting.xml
in searchbox.您可以通过按快捷键
Ctrl+3
来验证Setting.xml
位置,您将在Eclipse
右上角看到Quick Access
,然后在搜索框中搜索setting.xml
。 If you got setting.xml it will show up in search.如果您有 setting.xml,它将显示在搜索中。 Click that, and it will open the window showing directory path wherever it is stored.
单击它,它将打开窗口,显示存储在何处的目录路径。 Your Maven Global Settings should be as such:
您的 Maven 全局设置应该是这样的:
Global Setting C:\\maven\\apache-maven-3.5.0\\conf\\settings.xml
全局设置
C:\\maven\\apache-maven-3.5.0\\conf\\settings.xml
User Setting %userprofile%\\\\.m2\\setting.xml
用户设置
%userprofile%\\\\.m2\\setting.xml
You can use global setting usually and leave the second option user setting
untouched.您通常可以使用全局设置,而保持第二个选项
user setting
不变。 Store your setting.xml in Global Setting将您的 setting.xml 存储在全局设置中
By Installing Maven you can not expect the settings.xml in your .m2 folder(If may be hidden folder, to unhide just press Ctrl+h).通过安装 Maven,您不能期望 .m2 文件夹中的 settings.xml(如果可能是隐藏文件夹,要取消隐藏只需按 Ctrl+h)。 You need to place the file explicitly at that location.
您需要将文件明确放置在该位置。 After placing the file maven plugin for eclipse will start using that file too.
为 Eclipse 放置文件 maven 插件后,也将开始使用该文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.