Reputation: 301
I am compiling my repo for maven project. I am getting some dependency errors. I know the maven central repository no longer supports insecure communication over plain HTTP and requires that all requests to the repository are encrypted over HTTPS.. This is what I tried adding the following code in
pom.xml
of my project:
<repositories>
<repository>
<id>central maven repo</id>
<name>central maven repo https</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
and in the
../maven/conf/settings.xml
added the following:
<profile>
<id>my profile</id>
<repositories>
<repository>
<id>central maven repo</id>
<name>central maven repo https</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
</profile
But nothing seems to work, I get the same error. Somewhere I saw that i need to change settings.xml in m2 path
~/.m2/settings.xml
but in my path i find this:
~/.m2> ls
repository wrapper
The error is as follows:
Failed to execute goal on project XXX: Could not resolve dependencies for project com.mycompany:XXX:war:1.0-SNAPSHOT: Failed to collect dependencies for [org.mongodb:mongo-java-driver:jar:3.6.2 (compile), javax.servlet:javax.servlet-api:jar:4.0.0 (compile), org.codehaus.jackson:jackson-mapper-asl:jar:1.9.9 (compile), com.google.guava:guava:jar:14.0 (compile), commons-lang:commons-lang:jar:2.1 (compile), org.geotools:gt-geojson:jar:22.0 (compile), org.geotools:gt-metadata:jar:22.0 (compile), org.geotools:gt-geojsondatastore:jar:20.2 (compile), com.xx:Demo:jar:1.0 (compile), javax:javaee-web-api:jar:7.0 (provided), org.apache.commons:commons-lang3:jar:3.9 (compile), com.googlecode.json-simple:json-simple:jar:1.1 (compile), javax.xml.bind:jaxb-api:jar:2.2.11 (compile), com.sun.xml.bind:jaxb-core:jar:2.2.11 (compile), com.sun.xml.bind:jaxb-impl:jar:2.2.11 (compile), javax.activation:activation:jar:1.1.1 (compile)]: Failed to read artifact descriptor for org.geotools:gt-geojson:jar:22.0: Could not transfer artifact org.geotools:gt-geojson:pom:22.0 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/geotools/gt-geojson/22.0/gt-geojson-22.0.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]
Not sure what I am doing wrong, the error still persists.
Upvotes: 2
Views: 4648
Reputation: 12345
You should avoid adding/updating repositories in thepom, see https://blog.sonatype.com/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/ for the details.
The preferred way to solve this is:
<settings>
...
<mirrors>
<mirror>
<id>central-https</id>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
</settings>
Upvotes: 0
Reputation: 61
I encountered the same problem while working on a j-ee that runs on payara. To build your project, please ensure that you first stop your payara server first
Upvotes: 1
Reputation: 16196
Because pom.xml
files themselves may contain <repository>
elements, it is entirely possible that a transitive dependency of yours is specifying a URL to a Maven repository that begins with http
. Tracking these down can be difficult.
Upvotes: 0