Netbeans + Maven (Updating Central Repositories)

瘦欲@ 提交于 2020-05-15 09:36:09

问题


I recently faced issues building my project due to "HTTPS Required" error. This issue was solved by modifying my pom.xml as described here, adding the following:

    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

However, it is a hassle to update every pom.xml, for every project I have.

I have tried adding that same code snippet to my settings.xml, to no avail.

I am aware newer versions of Maven resolve this issue. However, due to work constraints, I'm unable to update my environment.

I have currently installed Java 8, and Maven, as bundled by Netbeans 8.2 Installer.

Is there something I can add to my settings.xml to avoid modifying every pom.xml I work on? If absolutely necessary, is there a way I can update just my maven version, knowing I have whatever is installed along with Netbeans?

Hope this isn't a duplicate, I have searched several entries, all to no avail.


回答1:


If you are using NetBeans 8.0 (8.1,8.2) with bundled maven also you could edit settings.xml. For example, for bundled maven with NetBeans 8.1, the file should be in directory C:\Program Files (x86)\NetBeans 8.1\java\maven\conf.

Just add another mirror with https protocol like that.

<mirrors>
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>central</mirrorOf>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </mirror>
  </mirrors>

If you have many pom.xml files editing repository settings in one place is better. Also, consider updating to NetBeans 11.0 LTS or latest Maven.



来源:https://stackoverflow.com/questions/60084842/netbeans-maven-updating-central-repositories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!