Non-resolvable parent POM in MAVEN Project - spring-boot

I'm trying to add dependencies to my maven project. I want to add spring boot configuration. but it gives this error in parent tag,
Project build error: Non-resolvable parent POM for
io.javabrains.springbootquickstart:course-api:0.0.1-SNAPSHOT: Failure
to find
org.springframework-boot:spring-boot-starter-parent:pom:1.4.2.RELEASE
in 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 and
'parent.relativePath' points at wrong local POM
I tried with adding relative path to this. But it didn't seem to work out.
<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>io.javabrains.springbootquickstart</groupId>
<artifactId>course-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Java Brains course API</name>
<parent>
<groupId>org.springframework-boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath>../course_api/pom.xml</relativePath>
</parent>
</project>

You’ve made a small typo in the configuration of your project’s parent. You have used a - rather than a .. You have org.springframework-boot and it should be org.springframework.boot.
Your parent should be the following:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>

Related

Spring Boot 2.2.1 RELEASE build error-relative path

Am adding spring-boot parent in my pom.xml file as given below
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1 RELEASE</version>
<relativePath/>
</parent>
i was change version version definition into <properties> tag as given below
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot.version>2.2.1.RELEASE</spring-boot.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring-boot.version}</version>
<relativePath/>
</parent>
after this change am getting build error
Project build error: Non-resolvable parent POM for abc:abc:7.0.0.0: Failure to find org.springframework.boot:spring-boot-starter-parent:pom:${spring-boot.version} in 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 and 'parent.relativePath' points at no local POM
i tried following solutions
<relativePath/> to <relativePath>/<relativePath>
<relativePath/> to <relativePath>../pom.xml/<relativePath>
Updated maven project
And also i tried following link
stackoverflow
There is no way not to inherit properties from a parent POM. Properties defined in a parent are visible in the child.

Maven multi-module non-resolvable parent

i'm facing a build error in maven, which i'm unable to explain, my project layout is:
root
|--parent
|--project
where root (aggregator) and project both use "parent" as their parent.
i used this layout in another project, which maven is able to build.
however, in this project, if i'm trying to build, i get a failure on non-resolvable parent pom:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for maven.test:maven-test-project:9.9.9-SNAPSHOT: Could not find artifact maven.test:maven-test-parent:pom:9.9.9-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 11, column 10
if i remove the parent node from the root (aggregator) pom, maven is able to build the project successfully.
if i use an older version of maven (3.3 instead of 3.6) the project is built successfully as well.
here are the poms for all 3 projects:
root
<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>maven.test</groupId>
<artifactId>maven-test</artifactId>
<version>9.9.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Test</name>
<parent>
<groupId>maven.test</groupId>
<artifactId>maven-test-parent</artifactId>
<version>9.9.9-SNAPSHOT</version>
<relativePath>parent/pom.xml</relativePath>
</parent>
<modules>
<module>parent</module>
<module>project</module>
</modules>
</project>
parent
<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>maven-test-parent</artifactId>
<version>9.9.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Parent</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
</project>
project
<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>
<artifactId>maven-test-project</artifactId>
<version>9.9.9-SNAPSHOT</version>
<name>Maven Project</name>
<parent>
<groupId>maven.test</groupId>
<artifactId>maven-test-parent</artifactId>
<version>9.9.9-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
</project>
There's a conception issue.
"root" cannot be at the same time a parent and child of the same Maven module "parent".

Versions Maven Plugin update-parent checks online maven

I have 2 maven projects in- parent and child, both having 0.0.1-SNAPSHOT.
The pom of parent:
<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.tmn</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
The pom of child:
<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.tmn</groupId>
<artifactId>child</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.tmn</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<name>child</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
I updated the version of the parent pom to some release version, say 1.0.0 and did mvn clean install on my parent. So, my maven local repo contains the released pom. Now, I want to update the parent.version and the version of my child pom. I run
mvn versions:update-parent -DparentVersion=1.0.0 -DgenerateBackupPoms=false -Dmaven.repo.local=/path/to/repo
I want it to blindly update the parent.version to the parentversion I supply in my command. But I get this WARNING and it is not updated.
artifact com.tmn:parent: checking for updates
[WARNING] Not updating version: could not resolve any versions
There is a similar issue logged here but I didn't understand the solution to this: https://github.com/mojohaus/versions-maven-plugin/issues/121

Maven insist using local parent rather than remote WITHOUT relativePath mentioned

I have a test project which is based on a parent project. This parent is build beforehand and is available on local artifactory server. The parent project is not available locally and this should stay this way.
As you see I am not using the relativePath element.
Still, when running "mvn clean install -U" I get an error about missing parent.
[ERROR] Non-resolvable parent POM for com.test.example:test:0.0.1-SNAPSHOT: Could not find artifact com.test:projects-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 6, column 10 -> [Help 2]
The test project pom.xml is:
<?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.test.example</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<parent>
<groupId>com.test</groupId>
<artifactId>projects-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
...
</dependencies>
<build>
...
</build>
</project>
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
<groupId>com.test</groupId>
<artifactId>projects-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
</project>
According to this, the default value for <relativePath> is ../pom.xml, so Maven will look locally first.
If you want to force the lookup to occur in your repository manager, use this trick:
<parent>
<groupId>com.test</groupId>
<artifactId>projects-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath/> <!— This forces a lookup against the repo —>
</parent>

How to configure/override Maven property used as parent version in dependencies?

Suppose there are two 3rd-party Maven artifacts with the following POM.XMLs:
artifact1 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>group1</groupId>
<artifactId>artifact1</artifactId>
<version>${artifact1.version}</version>
<packaging>pom</packaging>
<properties>
<artifact1.version>0.0.1-SNAPSHOT</artifact1.version>
</properties>
<modules>
<module>../artifact2</module>
</modules>
artifact2 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>
<artifactId>artifact2</artifactId>
<parent>
<groupId>group1</groupId>
<artifactId>artifact1</artifactId>
<version>${artifact1.version}</version>
<relativePath>../artifact1</relativePath>
</parent>
They are built normally using
mvn clean install
Now, if I try to reuse artifact2 in a 3rd 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>group2</groupId>
<artifactId>artifact3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>group1</groupId>
<artifactId>artifact2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
After executing...
mvn clean install
...the build fails trying to locate group1:artifact1:pom:${artifact1.version}
[ERROR] Failed to execute goal on project artifact3: Could not resolve dependencies for project group2:artifact3:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at group1:artifact2:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for group1:artifact2:jar:0.0.1-SNAPSHOT: Could not find artifact group1:artifact1:pom:${artifact1.version} in central (https://repo.maven.apache.org/maven2) -> [Help 1]
And setting the property in the command-line doesn't work either:
mvn clean install -Dartifact1.version=0.0.1-SNAPSHOT
How can I use artifact2 as a dependency?
<parent> doesn't allow variables. Because in order to get a list of variables Maven first has to build Effective POM and for this it needs to resolve parents.
Even if there is some version of Maven that allowed such module to be installed it's not a working solution in general. Maven's ideology is that all the dependencies (including parent) could be downloaded from a repo and are not necessarily present on local FS/in the reactor. With properties in the parent dependency definition you violate this rule.

Resources