Non-resolvable parent POM for " ":0.0.1-SNAPSHOT: Could not find artifact " ":pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM - jpa

As the title describes it is an "Non-resolvable parent POM for Could not find artifact and 'parent.relativePath' points at wrong local POM" problem, found often on stackoverflow, but i haven't found a matching one. So here's my problem description
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.salamoneleonardo:facturacion-rest:0.0.1-SNAPSHOT: Could not find artifact com.salamoneleonardo:ventas:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 15, column 13
[FATAL] Non-resolvable parent POM for com.salamoneleonardo:facturacion-logic:0.0.1-SNAPSHOT: Could not find artifact com.salamoneleonardo:ventas:pom:0.0.1-SNAPSHOT and 'parent.relativeyec - copia\ventas\proyecto-ventas\facturacion-persistencia\src\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for com.salamoneleonardo:facturacion-persistencia:0.0.1-SNAPSHOT: Could not find artifact com.salamoneleonardo:ventas:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 15, column 13
I leave the POM below
Pom main
<modelVersion>4.0.0</modelVersion>
<groupId>com.salamoneleonardo</groupId>
<artifactId>ventas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ventas</name>
<url>https://start.spring.io</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>facturacion-rest/src</module>
<module>facturacion-logic/src</module>
<module>facturacion-persistencia/src</module>
</modules>
Pom rest
<modelVersion>4.0.0</modelVersion>
<artifactId>facturacion-rest</artifactId>
<name>facturacion-rest</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.salamoneleonardo</groupId>
<artifactId>ventas</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependency>
<groupId>com.salamoneleonardo</groupId>
<artifactId>facturacion-logic</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
POM logic
<modelVersion>4.0.0</modelVersion>
<artifactId>facturacion-logic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>facturacion-logic</name>
<parent>
<groupId>com.salamoneleonardo</groupId>
<artifactId>ventas</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.salamoneleonardo</groupId>
<artifactId>facturacion-persistencia</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
POM persistence
<modelVersion>4.0.0</modelVersion>
<artifactId>facturacion-persistencia</artifactId>
<name>facturacion-persistencia</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>11</java.version>
</properties>
<parent>
<groupId>com.salamoneleonardo</groupId>
<artifactId>ventas</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

Related

Maven module jar missing

I've got a multi-modules maven project and I'm trying to add a module to my project. I know a lot of questions have been asked but it didn't solved my problem. When I deploy my project, the .jar of my new module is not registered whereas my others modules are working properly.
I've added the new module in the pom of my parent module in my dependency management:
<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.project</groupId>
<artifactId>project-parent</artifactId>
<version>1.0.33-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>base</module>
<module>mynewmodule</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.project</groupId>
<artifactId>base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.project</groupId>
<artifactId>mynewmodule</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
About the pom of the new module, I've specified the packaging to jar:
<?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>com.project</groupId>
<artifactId>project-parent</artifactId>
<version>1.0.33-SNAPSHOT</version>
</parent>
<artifactId>mynewmodule</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.project</groupId>
<artifactId>base</artifactId>
</dependency>
</dependencies>
</project>
I've also done a maven build project.
I don't understand then why when I deploy my project with Jenkins, the jar of my new module is missing. Have I missed something?

SpringBootApplication can not be resolved to a type error in Spring tool suite and maven

I have created the maven project in spring tool suite. I created the pom.xml with required dependencies but facing error as "SpringBootApplication can not be resolved to a type".
I have tried a couple of solutions like Maven -> Update Project..., Clean Project, deleted local repository directory of Maven (.m2), etc... also I tried creating another maven project but still the same error.
I think this is eclipse spring tool suite problem with maven.
Is there any solution like patch by eclipse or anything else?
Thanks in advance!
Pom.xml as follows
<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>cource.api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Java Brains Cource API</name>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
</parent>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<properties>
<java.version>1.8</java.version>
</properties>
</project>
You did not add the correct dependencies.
You should add
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
as a dependency (in <dependencies>) instead of spring-boot-starter-parent.
Parent just defines the versions but does not actually add any dependency (you use it as a <parent> in Maven).
If you have test, also add spring-boot-starter-test.
I would also suggest to use https://start.spring.io/ to generate a working Spring Boot base project (also available from STS in File->new->Other->Spring Starter 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>
<groupId>io.javabrains.springbootquickstart</groupId>
<artifactId>cource.api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Java Brains Cource API</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<properties>
<java.version>1.8</java.version>
</properties>
</project>
Copy/Paste it in your POM.xml. Update the Maven project and it will fetch the required JARs.

Problems with Pom.xml

I hope you guys can help me out.
I want to make a simple webLogin (Maven project) so far my code works. Now to make a build and deploy it i had to look into poms and i really tried but i don't know what i am doing wrong. Maybe someone knows how to do it right
My project tree:
pom.xml(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>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>LoginTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
pom.xml(app)
<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>src.main.java</groupId>
<artifactId>app</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>/pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
<exclude-ui>false</exclude-ui>
<api.ctx.root>/rest</api.ctx.root>
<ui.ctx.root>/webui</ui.ctx.root>
</properties>
</profile>
</profiles>
</project>
pom.xml(rest)
<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>src.main.java</groupId>
<artifactId>rest</artifactId>
<packaging>war</packaging>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>src.main.java.app</groupId>
<artifactId>Login.java</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
<packagingExcludes>WEB-INF/lib/*intf*.jar,WEB-INF/lib/*shared*.jar</packagingExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml(webui)
<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>src.main.java</groupId>
<artifactId>webui</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>LoginTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
<exclude-ui>false</exclude-ui>
<api.ctx.root>/rest</api.ctx.root>
<ui.ctx.root>/webui</ui.ctx.root>
</properties>
</profile>
</profiles>
</project>
This is what i get right now and im sure this will not be the last ERROR i get..
[ERROR] Non-resolvable parent POM for src.main.java:app:1.0.0: Could not find artifact org.apache.maven:LoginTest:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 12, column 10 -> [Help 2]
Maybe someone can help me thanks in advance
Your project structure seems to be broken. You usually have one pom per project, and especially you should not have pom files in the src/main/java. If you want to define modules (subprojects) they need to have their own inner structure (as every Maven project).

Package does not exist when using Maven

<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.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mavenproject1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When I try to import com.mongodb, I get a package does not exist error. I had to manually add the .jar file to make it work. How do I get Maven dependency to work?
Thank you
You have the maven coordinate correct, and the artifact does exist on maven central repository. So I strongly believe your maven settings had configuration problem causing it unable to fetch from central repository.
This commonly occur when you're behind a company internal repository such as nexus and it has stale index, or you set your ~/.m2/settings.xml to NOT lookup from the central repo.

Creating multi module Maven Projects in Eclipse

Trying to create a multi module maven project in eclipse.
Parent 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>parent</groupId>
<artifactId>proj1</artifactId>
<version>${myversion}</version>
<packaging>pom</packaging>
<properties>
<myversion>1.0.0</myversion>
</properties>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
Child-Module 1 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>proj1</artifactId>
<groupId>parent</groupId>
<version>${myversion}</version>
</parent>
<groupId>parent</groupId>
<artifactId>child1</artifactId>
<version>${myversion}</version>
</project>
Child Module 2 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>proj1</artifactId>
<groupId>parent</groupId>
<version>${myversion}</version>
</parent>
<groupId>parent</groupId>
<artifactId>child2</artifactId>
<version>${myversion}</version>
<dependencies>
<dependency>
<groupId>parent</groupId>
<artifactId>child1</artifactId>
<version>${myversion}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
If I use mvn clean install on command line from the parent folder I can build find. All the projects are build successfully.
But in eclipse I keep getting an error for Child Module 2 pom.xml
Description Resource Path Location Type
parent:child1:1.0.0:jar Missing:
----------
1) parent:proj1:pom:${myversion}
----------
1 required artifact is missing.
for artifact:
parent:proj1:pom:${myversion}
from the specified remote repositories:
central (http://repo1.maven.org/maven2, releases=true, snapshots=false)
pom.xml /child2 line 1 Maven Problem
I need to achieve 2 things
1. have a maven property define the version in the parent pom file.
2. use this property to define the version in all the child modules.
What should I do? I am stuck. Please help.
I am using Eclipse Galileo with m2Eclipse
This can't work, you can't get the version of the parent to use from the parent (and actually, properties don't get substituted in the parent element, see MNG-624). So you need to hard code the version and your parent POM should be:
<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>parent</groupId>
<artifactId>proj1</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
And in your child POM 1. you need to hardcode the version in /project/parent/version 2. you don't need to specify the <version> (you inherit it) 3. use the ${project.version} property in dependencies.
<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>
<parent>
<artifactId>proj1</artifactId>
<groupId>parent</groupId>
<version>1.0.0</version>
</parent>
<groupId>parent</groupId>
<artifactId>child2</artifactId>
<!--version>${myversion}</version--> <!-- Inherited -->
<dependencies>
<dependency>
<groupId>parent</groupId>
<artifactId>child1</artifactId>
<version>${project.version}</version> <!-- use the built-in property here -->
<!--type>jar</type--> <!-- This is a default, you can omit it -->
<!--scope>compile</scope--> <!-- This is a default, you can omit it -->
</dependency>
</dependencies>
</project>
Versionless parent elements will be supported in Maven 3.1.
See also
Missing artifact error in Maven
Eliminate Maven POM Redundancy
Maven 3 - Worth it???