简体   繁体   English

Eclipse中的Maven插件-缺少Settings.xml文件

[英]Maven plugin in Eclipse - Settings.xml file is missing

I installed the maven plugin for eclipse. 我为Eclipse安装了Maven插件。 Then tried updating the index and got the following error: 然后尝试更新索引并得到以下错误:

Unable to update index for central|http://repo1.maven.org/maven2 无法更新中央索引| http://repo1.maven.org/maven2

While trying to edit the proxy settings through windows-preferences-maven-user settings, I realise there is no such file. 在尝试通过Windows-preferences-maven-user设置编辑代理设置时,我意识到没有这样的文件。 I don't have separate maven installation and only the plugin. 我没有单独的Maven安装,只有插件。 Please someone could help resolving the problem? 请有人可以帮助解决问题吗? Thank you very much. 非常感谢你。

Cheers A 干杯

Config: Helios Service Release 1 org.maven.ide.eclipse.feature (0.12.0.20101115-1102) "Maven Integration for Eclipse" 配置:Helios Service Release 1 org.maven.ide.eclipse.feature(0.12.0.20101115-1102)“针对Eclipse的Maven集成”

The settings file is never created automatically, you must create it yourself, whether you use embedded or "real" maven. 设置文件永远不会自动创建,无论您使用嵌入式还是“真实” Maven,都必须自己创建。

Create it at the following location <your home folder>/.m2/settings.xml eg C:\\Users\\YourUserName\\.m2\\settings.xml on Windows or /home/YourUserName/.m2/settings.xml on Linux 在以下位置<your home folder>/.m2/settings.xml C:\\Users\\YourUserName\\.m2\\settings.xml <your home folder>/.m2/settings.xml创建它,例如在Windows上为C:\\Users\\YourUserName\\.m2\\settings.xml或在Linux上是/home/YourUserName/.m2/settings.xml

Here's an empty skeleton you can use: 这是您可以使用的空骨架:

<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
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings>

If you use Eclipse to edit it, it will give you auto-completion when editing it. 如果使用Eclipse编辑它,它将在编辑时自动完成。

And here's the Maven settings.xml Reference page 这是Maven settings.xml参考页面

Working on Mac I followed the answer of Sean Patrick Floyd placing a settings.xml like above in my user folder /Users/user/.m2/ 在Mac上工作时,我遵循了Sean Patrick Floyd的回答,将如上所述的settings.xml放在我的用户文件夹/Users/user/.m2/中。

But this did not help. 但这并没有帮助。 So I opened a Terminal and did a ls -la on the folder. 因此,我打开了一个终端,并在文件夹上执行了ls -la This was showing 这表明

-rw-r--r--@

thus staff and everone can at least read the file. 这样员工所有人都至少可以读取该文件。 So I wondered if the message isn't wrong and if the real cause is the lack of write permissions. 所以我想知道消息是否正确,真正的原因是否是缺少写入权限。 I set the file to: 我将文件设置为:

-rw-r--rw-@

This did it. 做到了。 The message disappeared. 消息消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM