Using SdmxSource jar files in the Nexus Repository through maven (m2eclipse) - java

The error Missing artifact org.sdmxsource:SdmxApi:jar:1.2.7 appears when defining dependencies in the m2eclipss.
I used this definition:
<dependency>
<groupId>org.sdmxsource</groupId>
<artifactId>SdmxApi</artifactId>
<version>1.2.7</version>
</dependency>
What may cause such a problem? Is there another way to import packages from nexus repository(eclipse IDE)?
Thanks in advance

Have you tried manually downloading the dependencies? See the sdmxsource help page: http://www.sdmxsource.org/sdmxsource-java/.
You could also use the parent tag in pom file:
<parent>
<artifactId>SdmxSourceBase</artifactId>
<groupId>org.sdmxsource</groupId>
<version>1.5.3</version>
</parent>
And the following repository in the maven settings.xml file:
<profiles>
<profile>
<id>sdmxsource</id>
<repositories>
<repository>
<id>MTRepo</id>
<url>http://sdmxsource.metadatatechnology.com/nexus/content/repositories/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>sdmxsource</activeProfile>
</activeProfiles>

Related

Maven failing to download artifact from central repository

I have two private JFrog repositories setup. One repository handles releases and the other handles snapshots. Here is how I have defined this in my settings.xml file.
<settings>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<servers>
<server>
<id>central</id>
<username>private-repo-username</username>
<password>private-repo-password</password>
</server>
<server>
<id>snapshots</id>
<username>private-repo-username</username>
<password>private-repo-password</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>a0d2olsx0t222-artifactory-primary-0-releases</name>
<url>https://my-private-repo.jfrog.io/artifactory/libs-release</url>
</repository>
<repository>
<id>snapshots</id>
<name>a0d2olsx0t222-artifactory-primary-0-snapshots</name>
<url>https://my-private-repo.jfrog.io/artifactory/libs-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
Multiple of my internal dependencies in my multi-module maven project are getting this error:
[ERROR] Failed to execute goal on project platform-utils: Could not resolve dependencies for project
design.colspalinva:platform-utils:jar:2.2.1-SNAPSHOT: The following artifacts could not be resolved:
com.maxmind.geoip2:geoip2:jar:2.12.0, org.apache.ant:ant:jar:1.10.5: Could not find artifact
com.maxmind.geoip2:geoip2:jar:2.12.0 in central (https://my-private-repo.jfrog.io/artifactory/libs-
release) -> [Help 1]
From the look of it, it doesn't appear that Maven is trying to reach out to the official Maven Central repo for those dependencies, rather failing on my private repository. I was under the impression that if the private repository does not contain the specific artifact, it will attempt to reach out to Maven Central.
It has no problem downloading my Spring dependencies from Maven Central.
If you like to redirect all access of central from Maven to your own repository manager you have to configure the settings.xml as follows:
<! language:language-xml ->
<?xml version="1.0" encoding="UTF-8"?>
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://IP:PORT/repository/repo</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
The Maven settings.xml configuration you shared seems to be OK. You are overriding the built-in central and snapshot repositories of Maven, which is the correct way to make sure that Maven send requests by default to Artifactory.
Adding a Mirror Any setting, as suggested in the other answer, means that in addition to overriding built-in Maven repositories, you can use the Mirror Any setting to redirect all requests to a Maven repository through Artifactory, including those defined inside POMs of plug-ins and third party dependencies.
According to the log you shared Maven does attempt to resolve the artifacts via Artifactory - https://my-private-repo.jfrog.io/artifactory/libs-release
The issue seems to be related to resolution of a specific artifact(s)in Artifactory.
I'm assuming that libs-release is a virtual Maven repository and that it contains at least one remote Maven repository pointing at Jcenter or Maven Central (if not please start by looking at Maven Repositories).
To debug the issue:
(1) Try resolving the artifact directly from Artifactory using cURL or a web browser, for example:
curl -Uuser:pass https://my-private-repo.jfrog.io/artifactory/libs-release/com/maxmind/geoip2/geoip2/2.12.0/geoip2-2.12.0.jar
(2) If you manage to resolve the artifact, it mean that Artifactory is properly configured and Maven should be able to resolve. If not, try looking for the reason performing a trace, for example:
curl -Uuser:pass https://my-private-repo.jfrog.io/artifactory/libs-release/com/maxmind/geoip2/geoip2/2.12.0/geoip2-2.12.0.jar?trace

Intellij cannot find Maven Dependencies in pom.xml

I am new to the spring boot framework and I'm trying to import the Maven libraries, but I keep getting an error with my pom.xml. Please Help!
Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
Dependency 'org.springframework.boot:spring-boot-starter-web:' not found less... (Ctrl+F1)
Inspection info: Inspects a Maven model for resolution problems.
Plugin 'org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE' not found less... (Ctrl+F1)
Inspection info: Inspects a Maven model for resolution problems.
Here is my pom.xml below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cierra</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.4.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
This maybe due to the reason that it is not able to connect and transfer dependencies specified in pom.xml file. The details where it is trying to connect must be mentioned in your settings.xml under .m2 folder
Try adding the pluginRepositories in your pom.xml file:
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
try adding following repository elements inside repositories element in your pom.xml
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
If this set well, change your updatePolicy settings.
<repository>
<id>myRepo</id>
<name>My Repository</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
Refer question.
The problem was I was behind a proxy that was blocking my pom.xml from running properly. After using a VPN to run the application, it works fine now.
Change Your Maven Version Ad Check Again.
Install Maven and Then Go to File/setting/build,execution,.../build Tools/maven
And Change Maven Home Directory to Your Install Maven Directory

repositories vs pluginRepositories in maven settings.xml

I have the below settings.xml file in my ~/.m2/ folder:
<settings>
<profiles>
<profile>
<id>my-repositories</id>
<repositories>
<repository>
<id>thirdparty-repository</id>
<name>Thirdparty repository</name>
<url>https://mynexus/repository/thirdparty/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>thirdparty-plugin-repository</id>
<name>Thirdparty plugin repository</name>
<url>https://mynexus/repository/thirdparty/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>my-repositories</activeProfile>
</activeProfiles>
</settings>
For both repositories the same nexus group repository is used:
https://mynexus/repository/thirdparty/
If I remove the first one: thirdparty-repository I get the below error:
Failed to read artifact descriptor for junit:junit:jar:4.8.2: Could not transfer artifact junit:junit:pom:4.8.2 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Now If I re-enable it and instead remove the other one: thirdparty-plugin-repository I now get this error:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Only when I have them both enabled at the same time it works.
Why do I need both repositories and pluginRepositories that points to the same nexus repository?
Suppose that you had defined a plugin with some dependencies. These dependencies will be searched in all of your <pluginRepository> definitions. Something like this:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<dependencies>
<dependency>
<groupId>io.herd.common</groupId>
<artifactId>common-herd</artifactId>
<version>${common.version}</version>
</dependency>
</dependencies>
</plugin>
Even if you have a <repository> defined which contains the common-herd artifact, Maven will not downloaded it unless you also have a <pluginRepository> containing it. And of course, the common-herd artifact can not be present inside the Maven Central Repository.
I had this problem a few months ago and Maven only downloaded the specific plugin dependency after I added a <pluginRepository>
I had a pb like this, idk if it will help but with this code in my POM.xml my nexus pb were resolved
<distributionManagement>
<repository>
<id>nexus</id>
<name>releases</name>
<url>https://mynexus/repository/thirdparty/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>Snapshots</name>
<url>https://mynexus/repository/thirdparty/</url>
</snapshotRepository>
</distributionManagement>
and
<!-- download artifacts from this repo -->
<repositories>
<repository>
<id>nexus</id>
<name>Public</name>
<url>https://mynexus/repository/thirdparty/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
hope it helped
In Nexus there is defined a public group which should contain all needed repositories and there should no need to configure this in your own pom nor in the settings.xml file. Only the public group of Nexus should be configured
The only thing you need is to change the url in mirror with your own location...
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

Maven doesn't find last version of a dependency [duplicate]

This question already has answers here:
How to add local jar files to a Maven project?
(36 answers)
Closed 7 years ago.
I have to include fixedformat4j-root dependency in my pom.xml.
I get artifact info (group, version, ...) from the pom.xml of the project homepage:
https://github.com/jeyben/fixedformat4j/blob/master/pom.xml
When I store that info to my pom.xml, I got this error from m2e eclipse plugin:
Missing artifact
com.ancientprogramming.fixedformat4j:fixedformat4j-root:jar:1.4.0-SNAPSHOT
This is my pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
...
<dependencies>
...
<dependency>
<groupId>com.ancientprogramming.fixedformat4j</groupId>
<artifactId>fixedformat4j-root</artifactId>
<version>1.4.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray</id>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
...
</build>
<reporting>
...
</reporting>
</project>
How can I solve this error? Should I set a new repository? Where can I find the repository url from the project pom.xml?
Neither of the repositories you've listed in your POM contain that version of that artifact. They each contain several release versions, but no snapshots.
Looking at the source for this artifact it does appear to be at version 1.4.0-SNAPSHOT but that version has not been deployed to a repository. Either build it yourself locally (via mvn clean install) or reference one of the versions in the given repositories.

Maven artifact jar different name than version

I got a small question about Maven. I got a project my pom.xml
It has basically this repositories:
<repositories>
<repository>
<id>alfresco-mirror</id>
<name>Alfresco Public Mirror</name>
<url>http://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>alfresco-snapshots</id>
<name>Alfresco Public Snapshots</name>
<url>http://maven.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>alfresco</id>
<name>Alfresco Public </name>
<url>http://pipin.bluexml.com/nexus/content/repositories/thirdparty/</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
and this dependency:
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-web-service-client</artifactId>
<version>3.4.d</version>
<type>jar</type>
</dependency>
</dependencies>
I think the main problem is that jar file and version got different names.
How can I solve this?
I thank your help in advance.
PS: Just for save time, this dependency link location
Try adding a classifier node to see if that works:
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-web-service-client</artifactId>
<version>3.4.d</version>
<classifier>community</classifier>
<type>jar</type>
</dependency>
</dependencies>
You can see the reasoning behind that here. Long story short, classifiers are just appended to that artifact name right after the version number. They're not used all that often, but you do see them from time to time.

Categories

Resources