Spring Tool Suite Maven Configuration Problem - java

I am trying to import project in STS 4 & Eclipse Oxygen which is created using start.spring.io. Below is 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.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.eureka</groupId>
<artifactId>EurekaRegistry</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>EurekaRegistry</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I am getting below error.
Below things I tried.
Update Maven Project
Project Clean & Build
Check proper Java version is configured.
Still I am not able to resolve this. Any help is appreciated.

That's a bug on Eclipse, as you can see here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340
I fixed by adding this property to my pom.xml
<properties>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

I had the similar problem and found that it was because of <maven.jar.plugin.version>3.1.2</maven.jar.plugin.version> , when I used 3.1.1 version everything worked. Probably it will help you - if not, there could be another problem.

Related

Project 'org.springframework.boot:spring-boot-starter-parent:3.0.2' not found

I am new to api development. I imported this project from my friend but now I am getting these error.:-
Project 'org.springframework.boot:spring-boot-starter-parent:3.0.2' not found
Project 'org.springframework.boot:spring-boot-starter-parent:3.0.2' not found
Project 'org.springframework.boot:spring-boot-starter-parent:3.0.2' not found
Invalid content was found starting with element '{"http://maven.apache.org/POM/4.0.0":properties}'. One of '{"http://maven.apache.org/POM/4.0.0":packaging, "http://maven.apache.org/POM/4.0.0":url, "http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":developers, "http://maven.apache.org/POM/4.0.0":contributors, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":modules, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/4.0.0":ciManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":dependencies, "http://maven.apache.org/POM/4.0.0":repositories, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":build, "http://maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":profiles}' is expected.
Invalid content was found starting with element '{"http://maven.apache.org/POM/4.0.0":properties}'. One of '{"http://maven.apache.org/POM/4.0.0":packaging, "http://maven.apache.org/POM/4.0.0":url, "http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":developers, "http://maven.apache.org/POM/4.0.0":contributors, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":modules, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/4.0.0":ciManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":dependencies, "http://maven.apache.org/POM/4.0.0":repositories, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":build, "http://maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":profiles}' is expected.
Dependency 'org.springframework.boot:spring-boot-starter-web:' not found
Dependency 'org.springframework.boot:spring-boot-starter-web:' not found
Dependency 'com.mysql:mysql-connector-j:' not found
Dependency 'com.mysql:mysql-connector-j:' not found
Dependency 'org.springframework.boot:spring-boot-starter-test:' not found
Dependency 'org.springframework.security:spring-security-test:' not found
Dependency 'org.springframework.security:spring-security-test:' not found
Dependency 'com.google.firebase:firebase-admin:8.0.1' not found
Dependency 'com.google.firebase:firebase-admin:8.0.1' not found
Dependency 'com.google.firebase:firebase-admin:8.0.1' not found
Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found
Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found
Here is my pom.xml file :-
<?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>3.0.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.square</groupId>
<artifactId>square</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>square</name>
<description>square</description>
<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>8.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I tried to invalidate and restart cache. I don't know how to solve this problem. I am trying to solve this problem from yesterday but I am getting any solution to solve this problem. Someone please help me I am stucked here.
First of all, I noticed that you have a duplicate <properties> </properties>
I wasn't able to replicate your issue, Spring Boot 3 needs at least Java 17 to run, which is a requirement I do not currently have.
However, I migrated to version 2.6.4 which is compatible with Java version 11 and I noticed that you had the version of mysql-connector-j missing
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.31</version> // add version
<scope>runtime</scope>
</dependency>
Remove
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
Find below the full 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.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.square</groupId>
<artifactId>square</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>square</name>
<description>square</description>
<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.31</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>8.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
If you still want to use the same Spring Boot version that you currently have, make sure you have Java 17, and delete .m2 file if you think it might be a cache issue, and do the same changes regarding the properties tag and mysql version.
Hope this helps!

Dependency 'org.springframework.boot:spring-boot-starter-validation:2.5.1' not found

How can I solve the issue of "Dependency 'org.springframework.boot:spring-boot-starter-validation:2.5.1' not found" ?
My pom.xml file loks 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 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.5.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JavaDeveloperTask</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-validation</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>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
</plugins>
</build>
</project>
I have added
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
But it still gives me the error. What could be th cause of this?
#ekm0d. I had the same problem using the Intellij IDEA. Here what I did and worked for me after inserting this on pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Right-click on the project file.
Click on Maven
Click on Reload Project
Wait the poem.xml archive reload
I hope it works for you too :)
Works for me.
Central repo have this dependency: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-validation/2.5.1/
So i don't see why it should not work. Maybe there was some kind of network issue.
Try to remove it from local maven repo and download again.
You can find maven repo in your user home dir .m2, delete .m2/repository/org/springframework/boot/spring-boot-starter-validation/2.5.1 folder
You should try to close the project and re-open it, the dependency will get downloaded by itself.
Worked in my case.

Microservice project throws class not found on mvn package for classes present in commn-service

<?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.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.microservice.test</groupId>
<artifactId>wallet-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>wallet-service</name>
<description>Wallet microservices</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
<jackson.version>2.9.0.pr3</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>com.microservice.test</groupId>
<artifactId>common-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I have created a project that is common-service and my every other projects uses classes from this project and it works fine but when create build of projects which uses common-service it throws classnotfoundexception for the classes which are present in common-service.
I have added dependency of common-service in other projects and added this project on build path also.
You didn't provide the pom of common-service. Is it of packaging type jar? Please ensure there is a <packaging>jar</packaging> in the other pom coordinates.
The dependencyManagement tag above is closed, but there is no opening.

pom.xml showing error after being downloaded from https://start.spring.io/

trying to follow a tutorial on developing web application with spring, thymeleaf, hibernate and mysql database. I created the project using https://start.spring.io/ after downloading the zip, pom.xml shows error marking the heading tag
i have ran maven build and maven clean, both is successful but the error still is not going.
//I get the error on the first line with no hint at all
<?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.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>net.codejava</groupId>
<artifactId>ProductManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ProductManager</name>
<description>Spring boot CRUD web app Example</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</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>
You can try to downgrade your boot version to 2.1.4.RELEASE
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
OR
update your maven version to the newest one. Download maven
If you are using eclipse then it's eclipse issue,if you can just run the spring project and check whether is it running fine?
If it's running then don't worry.
Sorry for lot's of assumption as the question is ambiguous.
I have faced same problem in eclipse.The projects generated from start.spring.io didn't have any packaging info jar/war.
<groupId>net.codejava</groupId>
<artifactId>ProductManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
Now it is not showing any after adding "packing". Later maven>update project

spring-boot-starter-web hibernate-validator dependency missing on Mac

I created spring boot project(Spring starter project) on STS(Spring tool suit), both of Window and Mac. 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>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.5.7.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>
Some of the dependency hierarchies are missing on Mac.
Example :
hibernate-validator
validation-api (missing on Mac)
jboss-loggin (missing on Mac)
classmate (missing on Mac)
I need that jars on Mac without modifying pom.xml.
I think I miss some environment Mac.
And I bought Mac 2 days ago. It's my first Mac.
If you want to use Hibernate Validator, you need to include it as explicit dependency:
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
Notice we don't specify version as Spring Boot will take care of it.
Other option is to use validation starter provided by Spring Boot:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Concerning your Windows/MacOS specific problems, it is some kind of misunderstanding. You need dependencies I mentioned. If you include them, it will work the same way on both platforms.

Categories