Maven 2.2.1 repository order seems arbitrary - java

My build is breaking on a fresh machine because one of the repositories is returning a 301 page for both the pom and jar instead of the expected 404. The dependency is asm:asm:1.3. It is in Central, but Maven doesn't seem to be looking there.
Here's a sample of the build log:
Downloading: http://download.java.net/maven/2/asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository java.net2 (http://download.java.net/maven/2)
Downloading: http://repository.primefaces.org/asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository prime-repo (http://repository.primefaces.org)
Downloading: https://repository.jboss.org/nexus/content/groups/public-jboss//asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/)
Downloading: http://maven.thebuzzmedia.com/asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository The Buzz Media Maven Repository (http://maven.thebuzzmedia.com)
Downloading: http://maven.glassfish.org/content/groups/glassfish/asm/asm/3.1/asm-3.1.pom
185b downloaded (asm-3.1.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '6c9fd3d150b8a5f0ca676f49b8ed603793cabebb'; remote = '<html>
<head><title>301' - RETRYING
Downloading: http://maven.glassfish.org/content/groups/glassfish/asm/asm/3.1/asm-3.1.pom
185b downloaded (asm-3.1.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '6c9fd3d150b8a5f0ca676f49b8ed603793cabebb'; remote = '<html>
<head><title>301' - IGNORING
[WARNING] POM for 'asm:asm:pom:3.1:compile' is invalid.
Here's the repositories section in my pom.xml:
<repositories>
<repository>
<id>central</id>
<name>Central Maven Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
</repository>
<repository>
<id>java.net2</id>
<name>Repository hosting the jee6 artifacts</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
<repository>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<id>jboss-public-repository-group</id>
<layout>default</layout>
<name>JBoss Public Maven Repository Group</name>
</repository>
<repository>
<id>The Buzz Media Maven Repository</id>
<url>http://maven.thebuzzmedia.com</url>
</repository>
</repositories>
I don't have a settings.xml file.
From what I can tell, the dependency on jersey-server-1.3 is breaking the build. Its pom.xml specifies the now non-existant repository at http://maven.glassfish.org/content/groups/glassfish. But all the other repositories I have specified are being checked in the order I have specified. That is, everything except central. How can I make Maven check the central repository first? Or at least make it check Central before using repositories specified in dependencies' poms?

The first recommendation i can make is to read the sonatype article about repositories in your pom. Furthermore the http code 301 means in move permanently. This means your URL you are using for one of your repositories seemed to be out of date or should be different.
The defined glassfish repository seemed to wrong, cause it should be an https connection.
Furthmore i can recommend to use a repository manager.
One questions comes to my mind: Why are you defining Maven Central in your repositories list, cause it's already defined in Maven itself...BTW: Repository definition should be put into the settings.xml instead of the pom.xml apart from using a repository manager.
To define the order of the repository access it is done in reverse order based on their definition in the settings.xml. To get better control over this is to use a repository manager.
One important question: Why don't you use Maven 3.0.X instead of Maven 2.2.1 ?

Related

Maven clean install jbossweb dependency unauthorized

On my project, i try to install it for the first time. But when i launch clean install, it can't download the dependency "jbossweb" because of unauthorized.
On mvnrepository( https://mvnrepository.com/artifact/org.jboss.web/jbossweb/7.4.10.Final) , it says this artifact is located at Spring Plugins repository (https://repo.spring.io/plugins-release/).
That is what I have in my pom.xml :
<repositories>
<repository>
<id>securecentral</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>spring</id>
<url>https://repo.spring.io/plugins-release/</url>
</repository>
</repositories>
And it define this dependency like this :
<dependency>
<groupId>org.jboss.web</groupId>
<artifactId>jbossweb</artifactId>
<version>7.4.10.Final</version>
</dependency>
The error when I launch clean install :
[ERROR] Failed to execute goal on project Pilotage_WS: Could not
resolve dependencies for project bpce:Pilotage_WS:war:1.0-SNAPSHOT:
Failed to collect dependencies at
org.jboss.web:jbossweb:jar:7.4.10.Final: Failed to read artifact
descriptor for org.jboss.web:jbossweb:jar:7.4.10.Final: Could not
transfer artifact org.jboss.web:jbossweb:pom:7.4.10.Final from/to
spring (https://repo.spring.io/plugins-release/): authentication
failed for
https://repo.spring.io/plugins-release/org/jboss/web/jbossweb/7.4.10.Final/jbossweb-7.4.10.Final.pom,
status: 401 Unauthorized -> [Help 1]
I don't understand, we need authentication ? If yes i couldn't find any information about this.
Moreover, when I go on https://repo.spring.io/plugins-release/, it redirects to https://repo.spring.io/ui/native/plugins-release/, but i cannot find the dependency here anyway.
Any idea ?
Try with JBoss repository:
<repositories>
...
<repository>
<id>jboss-releases</id>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</repository>
</repositories>

Maven clean failed and Maven install failed in command prompt [duplicate]

Recently Maven build jobs running in Jenkins are failing with the below exception saying that they couldn't pull dependencies from Maven Central and should use HTTPS. I'm not sure how to change the requests from HTTP to HTTPS. Could someone guide me on this matter?
[ERROR] Unresolveable build extension:
Plugin org.apache.maven.wagon:wagon-ssh:2.1 or one of its dependencies could not be resolved:
Failed to collect dependencies for org.apache.maven.wagon:wagon-ssh:jar:2.1 ():
Failed to read artifact descriptor for org.apache.maven.wagon:wagon-ssh:jar:2.1:
Could not transfer artifact org.apache.maven.wagon:wagon-ssh:pom:2.1 from/to central (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom.
Return code is: 501, ReasonPhrase:HTTPS Required. -> [Help 2]
Waiting for Jenkins to finish collecting data[ERROR]
Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1:
Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]
The reason for the observed error is explained in Central 501 HTTPS Required
Effective January 15, 2020, The Central Repository no longer supports
insecure communication over plain HTTP and requires that all requests
to the repository are encrypted over HTTPS.
It looks like latest versions of Maven (tried with 3.6.0, 3.6.1) are already using the HTTPS URL by default.
Here are the dates when the major repositories will switch:
Your Java builds might break starting January 13th (if you haven't yet switched repo access to HTTPS)
Update: Seems like from maven 3.2.3 maven central is accessed via HTTPS
See https://stackoverflow.com/a/25411658/5820670
Maven Change log
(http://maven.apache.org/docs/3.2.3/release-notes.html)
I am facing the same problem. There are two solutions that I tried, and both works fine for me.
Update the Maven version repository (Maven version >= 3.2.3)
Restrict the current Maven version to use HTTPS links.
Update the Maven version repository:
Download the Apache Maven binary that includes the default https addresses (Apache Maven 3.6.3 binary). And open the Options dialog window in tools of NetBeans menu bar (Java Maven Dialog View). And select browse option in Maven Home List Box (Maven Home List Box View). After adding the Apache Maven newly downloaded version (Updated Maven Home List Box View), the project builds and runs successfully.
Restrict the current Maven version to use HTTPS links:
Include the following code in pom.xml of your project.
<project>
...
<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>
</project>
Effective January 15, 2020, The Central Repository no longer supports
insecure communication over plain HTTP and requires that all requests
to the repository are encrypted over HTTPS.
If you're receiving this error, then you need to replace all URL
references to Maven Central with their canonical HTTPS counterparts.
(source)
We have made the following changes in my project's build.gradle:
Old:
repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}
New:
repositories {
maven { url "https://repo.maven.apache.org/maven2" }
}
Try to hit the below URL in any browser. It will return 501
http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom
Please try with https. It will download a pom.xml file:
https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom
Please add it (https://repo.maven.apache.org/maven2) in the setting.xml file:
<repositories>
<repository>
<id>Central Maven repository</id>
<name>Central Maven repository https</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
I was using a clean install of Maven/Java on a Docker container.
For me, I had to cd $M2_HOME/conf and edit the settings.xml file there. Add the following block inside <mirrors>...</mirrors>
<mirror>
<id>central-secure</id>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
Update the central repository of Maven and use https instead of http.
<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>
Add this in pom.xml file. It works fine for me
<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>
Maven is moving to HTTPS and disabling HTTP access
Short story, from January 15, 2020, Maven Central repository is not longer supporting HTTP connections (other repositories are doing the same). Therefore, you will indicate your Maven/Gradle settings to use an HTTPS URL.
Solution:
You can choose one of the following three approaches.
Add a repository in your project´s pom.xml file
<project>
...
<repositories>
<repository>
<id>central maven repo</id>
<name>central maven repo https</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
</project>
Add the repository into a profile in the settings.xml file.
<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>
Update you maven version to a new one that uses https values as default. The lastest one at this moment 3.6.3 Download here
For Gradle:
Only replace the URL for the HTTPS version.
repositories {
maven { url "https://repo.maven.apache.org/maven2" }
}
I was added following code segment to setting.xml and it was resolved the issue,
<mirrors>
<mirror>
<id>maven-mirror</id>
<name>Maven Mirror</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
I was using an outdated version of Maven (3.0.3 and 3.1). These older versions no longer supports http repositories (as mentioned above). Upgrading to Maven 3.6 was the fix for me.
As stated in other answers, https is now required to make requests to Maven Central, while older versions of Maven use http.
If you don't want to/cannot upgrade to Maven 3.2.3+, you can do a workaround by adding the following code into your MAVEN_HOME\conf\settings.xml into the <profiles> section:
<profile>
<id>maven-https</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
This will be always an active setting unless you disable/override it in your POM when needed.
I have the same issue, but I use GitLab instead of Jenkins. The steps I had to do to get over the issue:
My project is in GitLab so it uses the .yml file which points to a Docker image I have to do continuous integration, and the image it uses has the http://maven URLs. So I changed that to https://maven.
That same Dockerfile image had an older version of Maven 3.0.1 that gave me issues just overnight. I updated the Dockerfile to get the latest version 3.6.3
I then deployed that image to my online repository, and updated my Maven project ymlfile to use that new image.
And lastly, I updated my main projects POM file to reference https://maven... instead of http://maven
I realize that is more specific to my setup. But without doing all of the steps above I would still continue to get this error message
Return code is: 501 , ReasonPhrase:HTTPS Required
For me (corporate coder) also adding a mirror repository in the settings.xml fixed the issue. I am also using Maven inside a docker container.
<mirrors>
<mirror>
<id>https-mirror</id>
<name>Https Mirror Repository</name>
<url>https://repo1.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
For all the corporate coders, ideally,
if you get this error, it means that your code base is still being built from open-source community. You need to over ride the "central" repository with your in house company Maven repository manager.
You can go to your settings.xml and override your central repository URL from http:// to https://
<M2_HOME>/conf/settings.xml
Find the mirrors sections and add the following entry:
<mirror>
<id>other-mirror</id>
<name>Other Mirror Repository</name>
<url>https://other-mirror.repo.other-company.com/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
In the URL section, if you were using either http://repo1.maven.org/maven2/ or http://repo.maven.apache.org/maven2/ then
Replace http://repo1.maven.org/maven2/ with https://repo1.maven.org/maven2/
Replace http://repo.maven.apache.org/maven2/ with https://repo.maven.apache.org/maven2/
You need to ideally use your company source control management/repository URL over here. As this will block any contact with open source Maven repository community.
As mentioned in other answers, effective from 15 January 2020, the central Maven repository doesn't support insecure communication over plain HTTP.
If you are using Netbeans older version, you have to make changes in maven to use https over http
Open C:\Program Files\NetBeans8.0.2\java\maven\conf\settings.xml
and paste below code in between mirrors tag
<mirror>
<id>maven-mirror</id>
<name>Maven Mirror</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
It will force maven to use https://repo.maven.apache.org/maven2 url.
Using Ubuntu 16.04, java 1.8.0_201.
I un-installed old maven and installed Maven 3.6.3,
still got this error that Maven dependencies are failing with a 501 error.
Realized it could be a truststore/keystore issue associated with requiring https.
Found that you can now configure -Djavax options using a jvm.config file, see: https://maven.apache.org/configure.html.
As I am also using Tomcat I copied the keystore & truststore config from Tomcat (setenv.sh) to my jvm.config and then it worked!
There is also an option to pass the this config in 'export MAVEN_OPTS' (when using mvn generate) but although this stopped the 501 error it created another: it expected a pom file.
Creating a separate jvm.config file works perfectly, just put it in the root of your project.
Hopefully this helps someone, took me all day to figure it out!
Same issue is also occuring for jcenter.
From 13 Jan 2020 onwards, Jcenter is only available at HTTPS.
Projects getting their dependencies using the same will start facing issues. For quick fixes do the following in your build.gradle
instead of
repositories {
jcenter ()
//others
}
use this:
repositories {
jcenter { url "http://jcenter.bintray.com/"}
//others
}
The error:
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required.
Root cause analysis:
Maven central is expecting that the clients use https, but the client is making plain HTTP request only.
Therefore, the request for downloading the package named 'wagon-ssh-2.1.pom' had failed.
How to fix the problem?
Replace the URL "http://repo.maven.apache.org/maven2"
with "https://repo.maven.apache.org/maven2"
in pom.xml file or build.gradle file of the project.
My current environment does not support HTTPS, so adding the insecure version of the repo solved my problem: http://insecure.repo1.maven.org as per Sonatype
<repositories>
<repository>
<id>Central Maven repository</id>
<name>Central Maven repository insecure</name>
<url>http://insecure.repo1.maven.org</url>
</repository>
</repositories>
The following link got me out of the trouble,
https://support.sonatype.com/hc/en-us/articles/360041287334-Central-501-HTTPS-Required
You could make the changes either in your maven, apache-maven/conf/settings.xml.
Or, if you are specifying in your pom.xml, make the change there.
Before,
<repository>
<id>maven_central_repo</id>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
Now,
<repository>
<id>maven_central_repo</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
Note the change from http to https
Sharing this in case anyone needs it:
Old Gradle config( without Gitlab , Docker deployments , for simple projects)
repositories {
google()
jcenter()
maven { url "http://dl.bintray.com/davideas/maven" }
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'http://repo1.maven.org/maven2' }
maven { url 'http://jcenter.bintray.com' }
}
New config :
repositories {
google()
jcenter()
maven { url "https://dl.bintray.com/davideas/maven" }
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://repo1.maven.org/maven2' }
maven { url 'https://jcenter.bintray.com' }
}
Notice the https. Happy coding :)
Originally from https://stackoverflow.com/a/59796324/32453 though this might be useful:
Beware that your parent pom can (re) define repositories as well, and if it has overridden central and specified http for whatever reason, you'll need to fix that (so places to fix: ~/.m2/settings.xml
AND also parent poms).
If you can't fix it in parent pom, you can override parent pom's repo's, like this, in your child pom (extracted from the 3.6.3 default super pom, seems they changed the name from repo1 as well):
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url> <!-- the https you've been looking for -->
<layout>default</layout>
<snapshots>
<enabled>false</enabled> <!-- or set to true if desired, default is false -->
</snapshots>
</repository>
</repositories>
This error occured to me too. I did what Muhammad umer said above. But, it only solved error for spring-boot-dependencies and spring-boot-dependencies has child dependencies. Now, there were 21 errors. Previously, it was 2 errors. Like this:
Non-resolvable import POM: Could not transfer artifact org.springframework.cloud:spring-cloud-dependencies:pom:Hoxton.SR3 from/to central
and also https required in the error message.
I updated the maven version from 3.2.2 to 3.6.3 and java version from 8 to 11. Now, all errors of https required are gone.
To update maven version
Download latest maven from here: download maven
Unzip and move it to /opt/maven/
Set the path export PATH=$PATH:/opt/maven/bin
And, also remove old maven from PATH
On an old grails environment the only thing that works without upgrading is:
settings.xml
<settings>
<mirrors>
<mirror>
<id>centralhttps</id>
<mirrorOf>central</mirrorOf>
<name>Maven central https</name>
<url>http://insecure.repo1.maven.org/maven2/</url>
</mirror>
</mirrors>
</settings>
I downloaded latest eclipse and tarted to use from here https://www.eclipse.org/downloads/packages/release/ which resolved my problem.
I hit this problem with the latest version (August 2020) (after not using Maven on this machine for ages) and was scratching my head as to why it could still be an issue after reading these answers.
Turns out I had an old settings.xml sitting in the .m2/ folder in my home directory with some customisations from years ago.
However, even deleting that file didn't fix it for me. I ended up deleting the entire .m2 folder.
I don't think there was anything else in it except for downloaded resources. Maybe just deleting folders like repository/org/apache/maven/archetype would have been sufficient.
I downloaded the last netbeans version 12.2, and the problem was resolved.
Add the following repository in pom.xml.
<project>
...
<repositories>
<repository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
...
</project>

Why do I need to specify a repository in my settings.xml file

I've run into a strange Maven configuration issue that I have never encountered before, and am confused as to my solution.
I have a local Nexus server that I use as a mirror for everything. Until now, I've only had the following mirror in my settings.xml file:
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>WADA Nexus</name>
<url>https://nexus.domain.org/repository/Public/</url>
</mirror>
</mirrors>
However, I recently wanted to create my own custom parent pom that I have deployed to my Nexus repo. In my project, I have pointed to my parent pom:
<parent>
<groupId>org.domain</groupId>
<artifactId>root-pom</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
However when I now try to run my build, it fails with the following:
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not find artifact org.domain:root-pom:pom:1.0.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 9, column 10
For some reason, maven is not trying to look up the parent pom in my Nexus repo.
My only workaround was to define a random repository value in my settings.xml file:
<repositories>
<repository>
<id>nexus</id>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>https://www.google.com/anythingCanGoHere</url>
<layout>default</layout>
</repository>
</repositories>
Since I've mirrored all Repos/URLs, I can set that url to any value and maven will now pick up my parent pom.
So, why do I even need to specify the repository at all? Shouldn't maven automatically try to resolve the parent pom against maven central or some other default repository?
It is not a strange configuration issue, but simply a misunderstanding from your side. What you have done is to populate <distributionManagement/> in your parent POM and added a catch-all mirror in your settings.xml with your local Nexus instance and expect it to work.
Do you actually know what you are mirroring? No! The default, hardcoded repo in Maven is Maven Central. It is a release repo which does not contain any snapshots. Therefore you see the ERROR. The bogus repo is necessary to enable Maven to request snapshots from your Nexus instance otherwise it will only request releases. Nexus in turn has a repo group with Central and your hosted release and snapshots repos.
As long as you don't define any snapshot repos in your POMs (which you shouldn't) Maven will never be able to download any snapshots.

Could not resolve dependencies: org.springframework.transaction

I am not super confident in my understanding of Maven so bear with me:
My POM:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
Build:
[WARNING] The POM for org.springframework:org.springframework.transaction:jar:3.2.4.RELEASE is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.427 s
[INFO] Finished at: 2016-12-02T15:22:42-08:00
[INFO] Final Memory: 7M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project PROJECT: Could not resolve dependencies for project PROJECT:jar:1.0: Failure to find org.springframework:org.springframework.transaction:jar:3.2.4.RELEASE in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2 has elapsed or updates are forced -> [Help 1]
Looking in http://repo1.maven.org/maven2 this makes sense. org.springframework.transaction is indeed not present in the repository. So I went to this page and noticed that it says the artifact lives in the following repository:
https://artifacts.alfresco.com/nexus/content/repositories/public/
This time, looking through the repository I did find org.springframework.transaction at the directory matching the groupId and artifactId specified in my POM.
https://artifacts.alfresco.com/nexus/content/repositories/public/org/springframework/org.springframework.transaction/
However there is clearly no 3.2.4.RELEASE here. My co-worker's are able to build the project (though it has been some time since they checked it out fresh) and they remember running into a similar issue. I am a little confused as to why this feels like a repository issue though when we are all running the same POM.
As an aside, there are multiple other org.springframework dependencies that are resolving appropriately and I can see them in my ~/.m2, just not this one.
The org.springframework.transaction has the spring-tx artifact id.
I use this snippet in my pom and works seamlessly:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.2.4.RElEASE</version>
</dependency>
Ended up being an issue to having spring-context dependency in my pom. Apparently that does stuff for you? Getting rid of both spring-tx and org.springframework.transaction actually allowed them to be downloaded and accessed properly.
As #Vadim just answered, you just need to add your custom repo to your pom.
<repositories>
<repository>
<id>alfresco</id>
<name>your custom repo</name>
<url>http://repository.springsource.com/maven/bundles/releas‌​e</url>
</repository>
</repositories>
And then you can get your dependency by using:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
You can view the repository contents by using this link https://artifacts.alfresco.com/nexus/#nexus-search;quick~transaction
Also be carefull not to run maven with -o flag( or in offline mode ) for the first time in order to let maven to download the dependency.
Your .m2 does not have it and Maven tries to get it from defined repositories. You do not have them or you do not have a connection from Maven. (it is more likely from what error says as I remember). are you behind the proxy?
You need to define additional repositories. either in ~/.m2/settings.xml or inside POM on project level.
Something like that:
<repositories>
<repository>
<id>fuse-public-repository</id>
<name>FuseSource Community Release Repository</name>
<url>https://repo.fusesource.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repositories>
in settings.xml usually in one of the active profile element.
In POM just inside project.
PS. be sure you have connection to the repository URL. If you are behind proxy you need to define it as well in settings.xml

How to make m2e (maven integration for eclipse) know where to find dependencies?

When work in STS (springsource tool suite), open pom.xml file and check dependencies in "dependencies tab", add/select maven dependency will give 0 result found. We need edit pom.xml to add dependency by hand. Is there a way to let M2E know where to check repository to search dependency?
M2e by default searches maven central repository for artifacts. It downloads an index file which has artifact details. You can configure additional repositories to be searched by specifying the same in repository section of your settings.xml file. Do note that some repositories do not have this index file.
By default , all pom.xml will automatically extend the Super POM , which is located in the maven_installation_folder/lib/maven-x.x.x-uber.jar ==> package org.apache.maven.project ==> pom-4.0.0.xml . All the configuration specified in the Super POM is inherited by the POMs you created for your projects.
If you open pom-4.0.0.xml , you will find that the maven central repository http://repo1.maven.org/maven2/ is defined here . That means if you specify a <dependency> in your pom.xml , maven will try to download this dependency in the following orders:
Maven local repository (i.e your local hard disk)
Maven central repository specifed in the Super POM (i.e http://repo1.maven.org/maven2/)
Maven remote repository (Defined in the <repository> section of your pom.xml )
Normally , I will use some maven repository search engines , such as this , to find out the <dependency> of the libraries /frameworks /tools that I want to use and then paste them in the pom.xml
If the dependency exists in the Maven central repository , everything will be fine and it will be download to your local repository . However , if some of the <dependency> (eg Hibernate) cannot be found and downloaded from the Maven central repository , you can try to visit its official site to find out its repository link and paste them in the <repository> section of your pom.xml .For example , Hibernate require to define the jboss repository in the pom.xml like this:
<repositories>
<repository>
<id>repository.jboss.org</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
You can refer to this for the use of <repository>

Categories

Resources