Why does pom.xml file give an unknown error - spring-boot

I,m trying to learn spring boot and install spring boot to eclipse IDE. When I create my first project it shows an error in first line of pom.xml. It shows as unknown error.
I tried many solutions from stackoverflow. But none of them work for me.
Maven pom.xml error in eclipse
When maven says "resolution will not be reattempted until the update interval of MyRepo has elapsed", where is that interval specified?
My pom.xml as 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Can anyone help me for resolve this.

I got the same problem 2 weeks ago. Then, I fixed it with adding a line as below
<properties>
<!-- ... -->
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
And it seems the error was fixed in Eclipse already.
Just update your Eclipse or STS4. You may see m2e connector is involved in the update list.

Related

how do I solve "The selection cannot be launched" in eclipse STS

I am new to spring boot and I want to launch my first application using eclipse STS
but I am getting error
The selection cannot be launched and there are no recent launches.
Most answers I see on the web suggest creating main on one of my file
which I have done but the problem still persist
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 https://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.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.oshabz</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
My file structure and main file

How to use other's dependency from github packages in my own maven project

Recently, I try to add a maven dependency from github packages and exactly do what the pages said to me. That page looks like this.
this 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 https://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.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>ssotest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ssotest</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
...
<dependency>
<groupId>io.github.kaixindeken.TwTSSO</groupId>
<artifactId>twtsso</artifactId>
<version>0.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
and then I got this
Cannot resolve io.github.kaixindeken.TwTSSO:twtsso:0.3
Much appreciated if anybody can tell me why is that and how to fix it
Your Maven will automatically download all dependencies from Maven Central. There, the last (and only) version that currently exists is 0.2: https://search.maven.org/artifact/io.github.kaixindeken/TwTSSO
You could probably use the instructions from the README to install version 0.3 locally.

Maven POM.xml problem - Unknown error at top line ( <?xml version="1.0" encoding="UTF-8"?> )

I am setting up a project in STS with Spring starter project and added required dependencies like spring security and JSP. But the top line of pom file throwing an error as Unknown
Can anybody help me out to resolve this?
I am using STS 4
<?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.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>RememberMeApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RememberMeApp</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-mavenplugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Usually this should work without any error
This is the latest surprise Eclipse bug when using with Spring Boot 2.1.5 due to Spring Boot 2.1.5 upgrade maven-jar-plugin to 3.1.2
The workaround is to downgrade it to the previous version by adding the following to pom.xml :
<properties>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Non-resolvable parent POM in Maven Project made with http://start.spring.io/

I've created a Maven Project using Spring Initializr, but when I try to build it I get the following error:
[ERROR] The project com.example:demo:0.0.1-SNAPSHOT (/home/alessandro/Work/workspaces/demo/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.4.2.RELEASE from/to repo (http://artifactory.dev.*****.it/artifactory/repo): Failed to transfer http://artifactory.dev.*****.it/artifactory/repo/org/springframework/boot/spring-boot-starter-parent/1.4.2.RELEASE/spring-boot-starter-parent-1.4.2.RELEASE.pom. Error code 504, Gateway Time-out and 'parent.relativePath' points at no local POM # line 14, column 10 -> [Help 2]
the auto-generated pom.xml is the following:
<?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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I tried to specify a relative path inside the parent tag (like '../pom.xml') without success, can anyone help me please?
Thanks
Nothing to do with start.spring.io.
You most probably have a custom ~/.m2/settings.xml where everything (or Maven Central) is proxied to http://artifactory.dev.*****.it/artifactory/repo/
Failed to transfer http://artifactory.dev.*****.it/artifactory/repo/org/springframework/boot/spring-boot-starter-parent/1.4.2.RELEASE/spring-boot-starter-parent-1.4.2.RELEASE.pom.
If that artifactory server is supposed to fetch outside, maybe there's a network glitch or something. Regardless, please ask the admin of that server for help.

Spring Boot with spring-boot-starter-web fails to compile in maven

I am using jdk1.7 and spring boot 1.4.2.Release.I created a brand new Spring boot project from start.spring.io. It compiled fine. I tried to add the below dependency for exposing a REST web service.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I get the below error:
[ERROR] Failed to execute goal on project demo: Could not resolve
dependencies for project com.example:demo:jar:0.0.1-SNAPSHOT: Failed to
collect dependencies at org.springframework.boot:spring-boot-starter-
web:jar:1.4.2.RELEASE -> org.hibernate:hibernate-validator:jar:5.2.4.Final:
Failed to read artifact descriptor for org.hibernate:hibernate-
validator:jar:5.2.4.Final: Could not transfer artifact
org.jboss.shrinkwrap:shrinkwrap-bom:pom:1.2.2 from/to spring-ext
(http://repo.spring.io/ext-release-local/): repo.spring.io: Unknown host
repo.spring.io -> [Help 1]
It takes the http://repo.spring.io/ext-release-local link which does not have jboss related files.
Please let me know if I am doing something wrong.
Your pom should look like this
<?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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
after that you need to run it with command mvn spring-boot:run from the project directory
I hope this time it will defenetly work only need to copy and pase this pom content to your pom file
To build spring boot application from scratch you can follow the link
In my case, just adding the repository configuration to the pom.xml didn't work. I had to add the following code into /maven-installation-dir/conf/settings.xml file.
<mirror>
<id>central-proxy</id>
<name>central-proxy</name>
<url>http://corporate-intranet/repo/url</url>
<mirrorOf>central</mirrorOf></mirror>
I hope it helps someone.

Resources