I am a spring new bee,
trying to import gs-rest-service-complete into my STS , I am able to import but getting compilation error in pom.xml
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE from/to spring-releases (https://repo.spring.io/libs-release):
Connection refused: connect and 'parent.relativePath' points at wrong local POM "
Here's my pom.xml
<?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>org.springframework</groupId>
<artifactId>gs-rest-service</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
Can anyone guide what mistake I am doing?
Proxy is the problem.
You need to ensure the proxies section in either the global settings settings.xml under ([maven install]/conf/) or user settings (${user.home}/.m2 ) is configured correctly
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
</proxy>
</proxies>
Related
We have a company Nexus repository which has just a couple of private libraries but it mostly mirrors the public Maven Nexus repository.
The repository is on a private network which can only be accessed by VPN.
This is accessed using a settings.xml config like so (redacted)
User Settings.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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>FOOSNAPSHOTS</id>
<username>foo-publisher</username>
<password>12345</password>
</server>
<server>
<id>BARRELEASES</id>
<username>bar-publisher</username>
<password>12345</password>
</server>
</servers>
<mirrors>
<mirror>
<id>foo-nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://foo/repository/foo-maven-group/</url>
</mirror>
<mirror>
<id>bar-nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://foo/repository/bar-maven-group/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://foo/repository/hosted-foo-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>foo-snapshots-repo</id>
<url>https://foo/repository/hosted-bar-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
In a sample spring boot project, when trying to build a project when not connected to the VPN it fails because it cannot get plugins like the following.
[ERROR] No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/bobbytables/.m2/repository), foo-nexus (https://foo/repository/foo-maven-group/)] -> [Help 1]
This is annoying as it then requires to be on the VPN, is there a way to get Maven to download plugins from public repos?
Parent POM
<?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>
<parent>
<groupId>foo.shared-maven-parent</groupId>
<artifactId>shared-maven-parent-java</artifactId>
<version>1.202211110800.52-x6937aa5.master</version>
</parent>
<groupId>foo.bar-service</groupId>
<artifactId>bar-service</artifactId>
<packaging>pom</packaging>
<version>3.0-SNAPSHOT</version>
<name>bar-service</name>
<description>Foo Bar - Bar is Foo</description>
<modules>
<module>contract</module>
<module>server</module>
</modules>
<properties>
<mcu.version>${project.version}</mcu.version>
<!-- Project's contract version -->
<mcu.project.contract.version>1.202204111324.39-x6bb54a3.master</mcu.project.contract.version>
</properties>
</project>
Service POM
<?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>
<parent>
<groupId>foo.bar-service</groupId>
<artifactId>bar-service</artifactId>
<version>3.0-SNAPSHOT</version>
</parent>
<groupId>foo.bar/groupId>
<artifactId>server</artifactId>
<packaging>jar</packaging>
<name>Listing-command Server</name>
<description>Listing-command Server</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>foo.shared-maven-bom</groupId>
<artifactId>shared-maven-bom-chassis</artifactId>
<version>1.202211160925.72-xa9bdde9.master</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>foo.shared-commons.spring-boot</groupId>
<artifactId>jetty-server</artifactId>
<version>1.202211110857.90-xcb97a1c.master</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- Starter for Stackdriver Trace -->
</project>
How can I specify either at project or user level that I want plugins to download from the public repository?
Thanks
I just recently created my own nexus repository manager, and when I went to add it to my own project's settings.xml file, now none of my dependencies are resolving. Here is my POM.xml:
<?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>projectname</groupId>
<artifactId>projectname</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>projectname</name>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<snapshotRepository>
<id>maven-snapshots</id>
<url>https://nexus.repo.placeholder/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexus-releases</id>
<url>https://nexus.repo.placeholder/repository/maven-releases/</url>
</repository>
</distributionManagement>
<build>
<finalName>projectname</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.minuskube.inv</groupId>
<artifactId>smart-invs</artifactId>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>de.themoep</groupId>
<artifactId>inventorygui</artifactId>
<!--The following version may not be the latest. Check it before using.-->
<version>1.4.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.1</version>
</dependency>
</dependencies>
</project>
However, no longer are my dependencies resolving in my pom anymore.
settings.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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://repo.template/repository/maven-public/</url>
</mirror>
</mirrors>
<localRepository>${user.home}/.m2/repository</localRepository>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://maven.apache.org</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://maven.apache.org</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<servers>
<server>
<id>maven-releases</id>
<username>username</username>
<password>password</password>
</server>
<server>
<id>maven-snapshots</id>
<username>username</username>
<password>password</password>
</server>
</servers>
</settings>
All of my credentials are correct to connect to the Nexus system and such as well. Could it be because I have defined a new settings.xml? Do I need to put something in it to fetch the proper repositories for other dependencies as well?
Not able to add parent tag in pom.xml just like below. It keeps giving me an error saying "Project 'org.springframework.boot:spring-boot:2.3.2.RELEASE' not found
Inspection info: Inspects a Maven model for resolution problems." Could someone help please?
<?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>org.learning.springboot</groupId>
<artifactId>SpringBootApplication</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<artifactId>spring-boot</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.3.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
</dependencies>
</project>
Check first if repository is part of your project:
On maven central, I see:
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
So, as in here, add:
<project>
<!------ others lines -->
<pluginRepositories>
<pluginRepository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>https://repo.spring.io/plugins-release/</url>
</pluginRepository>
</pluginRepositories>
</project>
Or, in your case, a repository, as in the same thread:
<repository>
<id>repository.springframework.maven.release</id>
<name>Spring Framework Maven Release Repository</name>
<url>http://maven.springframework.org/milestone/</url>
</repository>
when trying to execute the maven-release-plugin's step perform, maven-deploy-plugin tries to download the maven-metadata.xml from SNAPSHOT and fails with
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project proxy-lib: Failed to retrieve remote metadata org.woezelmann.api-libs:proxy-lib:1.0.18-SNAPSHOT/maven-metadata.xml: Could not transfer metadata org.woezelmann.api-libs:proxy-lib:1.0.18-SNAPSHOT/maven-metadata.xml from/to woezelmannnexusreleases (https://my-respo/repository/releases): Failed to transfer file: https://my-respo/repository/releases/org/woezelmann/api-libs/proxy-lib/1.0.18-SNAPSHOT/maven-metadata.xml. Return code is: 400 , ReasonPhrase:Repository version policy: RELEASE does not allow metadata in path: org/woezelmann/api-libs/proxy-lib/1.0.18-SNAPSHOT/maven-metadata.xml.
Obviously there is no org.woezelmann.api-libs:proxy-lib:1.0.18-SNAPSHOT in my-repo, because I never deployed it. Can I skip this step somehow?
My pom.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>org.woezelmann.api-libs</groupId>
<artifactId>proxy-lib</artifactId>
<version>1.0.18-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<maven.compiler.version>3.3</maven.compiler.version>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
</properties>
<scm>
<developerConnection>scm:git:git#https://github.com/woezelmann/api-libs</developerConnection>
</scm>
<distributionManagement>
<repository>
<id>woezelmannexusreleases</id>
<url>https://my-repo/repository/releases</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>Global Repository</id>
<name>Global</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>spring-maven-release</id>
<name>Spring Maven Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
<repository>
<id>woezelmannexusreleases</id>
<name>Releases of artifacts</name>
<url>https://my-repo/repository/releases</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
I've had a fair amount of help with my Maven code and I'm currently trying to have my project deploy to a project determined by a variable. Here is my Pom.xml
<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>maven.Test</groupId>
<artifactId>Hello</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Artifactory</name>
<url>http://artifactory:8081/artifactory/webapp/home.html?0</url>
<repositories>
<repository>
<id>parentPomLocation</id>
<name>Artifactory</name>
<url>http://artifactory:8081/artifactory/dev</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<parent>
<groupId>dev</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
</project>
So my pom first pulls the parent Pom.xml from artifactory and checks it for it's distribution management. Here is the parent Pom.xml
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dev</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<distributionManagement>
<repository>
<id>Artifactory</id>
<name>Artifactory-releases</name>
<url>http://artifactory:8081/artifactory/${repo}</url>
</repository>
<snapshotRepository>
<id>Artifactory</id>
<name>Artifactory-snapshots</name>
<url>http://artifactory:8081/artifactory/${repo}</url>
</snapshotRepository>
</distributionManagement>
</project>
The parent Pom.xml's distribution url is determined through a variable I assign, this is the command line I run.
mvn deploy -D$repo=integration
But no matter what it always deploys to dev and not integration.