Why maven settings.xml file is not there?

后端 未结 7 890
感动是毒
感动是毒 2020-12-13 08:49

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 bel

相关标签:
7条回答
  • 2020-12-13 09:03

    The settings.xml file is not created by itself, you need to manually create it. 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>
    
    0 讨论(0)
  • 2020-12-13 09:03

    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:

    Global Setting C:\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

    0 讨论(0)
  • 2020-12-13 09:04

    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.

    Go to the location where you maven was unzipped.

    Direct to following path,

    \apache-maven-3.0.4\conf\ and copy the settings.xml file and paste it inside your .m2 folder.

    Now create a maven project.

    0 讨论(0)
  • 2020-12-13 09:06

    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.html for reference. The m2eclipse plugin will use the same settings file as the command line.

    0 讨论(0)
  • 2020-12-13 09:17

    As per the maven's documentation, there are two possible settings.xml locations

    One is the global maven's repo (Your initial download and subsequent unzipped files from apache maven) $M2_HOME/conf/settings.xml

    And the second is the user created one (Your local copy) ${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

    0 讨论(0)
  • 2020-12-13 09:18

    settings.xml is not required (and thus not autocreated in ~/.m2 folder) unless you want to change the default settings.

    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.

    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.

    0 讨论(0)
提交回复
热议问题