How to change Maven local repository in eclipse

前端 未结 6 1326
野的像风
野的像风 2020-12-04 14:29

I\'m importing a multiple-module Maven project from the root directory on a shared drive on another server A. On server A, mvn install will run successfully, an

6条回答
  •  粉色の甜心
    2020-12-04 14:59

    In general, these answer the question: How to change your user settings file? But the question I wanted answered was how to change my local maven repository location. The answer is that you have to edit settings.xml. If the file does not exist, you have to create it. You set or change the location of the file at Window > Preferences > Maven > User Settings. It's the User Settings entry at

    It's the second file input; the first with information in it.

    If it's not clear, [redacted] should be replaced with the local file path to your .m2 folder.

    If you click the "open file" link, it opens the settings.xml file for editing in Eclipse.

    If you have no settings.xml file yet, the following will set the local repository to the Windows 10 default value for a user named mdfst13:

    
    
      C:\Users\mdfst13\.m2\repository
    
    

    You should set this to a value appropriate to your system. I haven't tested it, but I suspect that in Linux, the default value would be /home/mdfst13/.m2/repository. And of course, you probably don't want to set it to the default value. If you are reading this, you probably want to set it to some other value. You could just delete it if you wanted the default.

    Credit to this comment by @ejaenv for the name of the element in the settings file: . See Maven — Settings Reference for more information.

    Credit to @Ajinkya's answer for specifying the location of the User Settings value in Eclipse Photon.

    If you already have a settings.xml file, you should merge this into your existing file. I.e. and should only appear once in the file, and you probably want to retain any settings already there. Or to say that another way, edit any existing local repository entry if it exists or just add that line to the file if it doesn't.

    I had to restart Eclipse for it to load data into the new repository. Neither "Update Settings" nor "Reindex" was sufficient.

提交回复
热议问题