eclipse 为什么 maven settings.xml 文件不存在?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5308079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why maven settings.xml file is not there?
提问by javanoob
I installed maven plugin for eclipse and was able to use it only in eclipse. I want to be able to run maven commands from terminal so installed maven as explained in the below link:
我为 eclipse 安装了 maven 插件,并且只能在 eclipse 中使用它。我希望能够从终端运行 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
我的问题是
- I could not find
settings.xml
in this path/home/raki/.m2/
-- What should I do for this? - Does the maven installed in the above step affects the maven installed in eclipse? These two mavens work independently or how is that?
- 我
settings.xml
在这条路上找不到/home/raki/.m2/
——我该怎么办? - 上面步骤安装的maven会影响eclipse安装的maven吗?这两个行家独立工作还是怎么回事?
回答by Raghuram
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). This means if some artifacts/dependencies are downloaded by standalone maven, it will not be again downloaded by maven in eclipse.
独立的 maven 和 eclipse 中的 maven 将使用相同的本地存储库(~/.m2 文件夹)。这意味着如果一些工件/依赖项是由独立的 Maven 下载的,它就不会被 Eclipse 中的 Maven 再次下载。
Based on the version of Eclipse that you use, you may have different maven version in eclipse compared to the standalone. It should not matter in most cases.
根据您使用的 Eclipse 版本,与独立版本相比,Eclipse 中的 Maven 版本可能不同。在大多数情况下应该无关紧要。
回答by WhiteFang34
Installation of Maven doesn't create the settings.xml
file. 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.htmlfor reference. The m2eclipse plugin will use the same settings file as the command line.
Maven 的安装不会创建该settings.xml
文件。您必须自己创建它。只需将它放在您.m2
期望的目录中,请参阅http://maven.apache.org/settings.html以供参考。m2eclipse 插件将使用与命令行相同的设置文件。
回答by Kermit_ice_tea
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 文件夹中,然后根据需要调整详细信息
回答by surendrapanday
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. If you got setting.xml it will show up in search. Click that, and it will open the window showing directory path wherever it is stored. Your Maven Global Settings should be as such:
您可以Setting.xml
通过按快捷方式来验证您的位置Ctrl+3
,您将Quick Access
在 右上角看到Eclipse
,然后setting.xml
在搜索框中搜索。如果您有 setting.xml,它将显示在搜索中。单击它,它将打开窗口,显示存储在何处的目录路径。您的 Maven 全局设置应该是这样的:
Global SettingC:\maven\apache-maven-3.5.0\conf\settings.xml
User Setting%userprofile%\\.m2\setting.xml
You can use global setting usually and leave the second option user setting
untouched. Store your setting.xml in Global Setting
全局设置C:\maven\apache-maven-3.5.0\conf\settings.xml
用户设置%userprofile%\\.m2\setting.xml
您通常可以使用全局设置,而user setting
保持第二个选项不变。将您的 setting.xml 存储在全局设置中
回答by Vijay Nandwana
The settings.xml
file is not created by itself, you need to manually create it. Here is a sample:
该settings.xml
文件不是自己创建的,您需要手动创建它。这是一个示例:
<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>
回答by Dulith De Costa
I also underwent the same issue as Maven doesn't create the settings.xml
file under .m2
folder. What I did was the following and it works smoothly without any issues.
我也遇到了同样的问题,因为 Maven 没有在settings.xml
文件.m2
夹下创建文件。我所做的是以下操作,它运行顺利,没有任何问题。
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 项目。
回答by pranav
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). You need to place the file explicitly at that location. After placing the file maven plugin for eclipse will start using that file too.
通过安装 Maven,您不能期望 .m2 文件夹中的 settings.xml(如果可能是隐藏文件夹,要取消隐藏只需按 Ctrl+h)。您需要将文件明确放置在该位置。为 Eclipse 放置文件 maven 插件后,也将开始使用该文件。