Maven missing default settings.xml

已回答

I do not like keeping my IDE data in c:\users\<myUser>\.m2 so I moved it to the D: drive and changed the appropriate settings to ensure that the location is found.

But on my first "maven install" I got the error indicating that the D: settings.xml file does not exist.  No problem I figured, I'll just copy it from the *\.m2 location... but there is none there to copy.

Where do I grab (or how do I create) a standard IntelliJ settings.xml file? (I have the Ultimate version in case that is relevant to the file contents)

0

By default there is no settings.xml file for Maven. If needed, you create one manually per https://maven.apache.org/settings.html.

0

It refuses to do a "maven install" without the settings.xml. 

I'll create one.  I assume that I only need to put in it the minimum necessary (maybe even just the open and close tags), right?  Or is there a minimum set of entries required?

0

Does it fail only in IntelliJ IDEA or in the command line Maven as well?

Did you override it in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | User settings file? Does it help if you disable the Override checkbox?

This file should not be needed for Maven builds unless you specify it as an option explicitly.

0

I don't have command line Maven installed.  I rely on Eclipse and IntelliJ IDEA's included versions of Maven.

Yes, I did override the location in the BuildTools configuration.  That is why I went to try and copy it from .m2 (and failed to find the file even though that is the "default" location) to the new location on my D: drive.

I can confirm that the file is not needed for builds.  But it *does* appear to be required to do a "maven install" to place the resulting JAR into the local repository... which of course is essential so that other projects that depend on it can find it.  When I try to do a maven install without the file it throws an error complaining that it is missing.  Probably because settings.xml is what tell Maven the location of the local repository.

0

Without settings.xml it should install into the default location. Make sure you do not override the settings file.

Install works fine and the artifact appears under E:\m2:

[INFO] Installing C:\work\attaches\demo\pom.xml to e:\m2\com\example\demo\1.0-SNAPSHOT\demo-1.0-SNAPSHOT.pom

1

And there is no "C:\Users\serge\.m2\settings.xml" file on my system.

0

Thanks, that worked for the project.

The install step now runs and the project shows in the local repository.

Also, I ended up consolidating the eclipse projects from the workspace into a single IntelliJ IDEA project (with each eclipse project presented as an IntelliJ module) and it seems to build fine.

0

1. File | New Projects Setup | Settings for New Projects.

2. Repositories are specified either in pom.xml or in settings.xml, refer to Maven documentation for details. IntelliJ IDEA just shows what Maven provides.

1

Perfect!!!  I had not seen that option in the File folder.

0

请先登录再写评论。