It might look like a duplicate of this question, but the solutions from it didn't work for me. I am getting an Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication at com.example.demo.Application.main error when I try to run the application using spring-boot. 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.blog</groupId>
<artifactId>module-8-16-springboot-webflow-thymeleaf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath />
</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.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.5.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>org.springframework.js</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</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.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- And other dependencies -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
JDK 1.8 and JRE 8 are installed on the system and worked fine before. I deleted the C:\Users\{username}\.M2\repository\org\springframework\boot directory on the system and forced Maven to reload the dependencies. Then I decompiled the file C:\Users\{username}\.M2\repository\org\springframework\boot\spring-boot\2.0.1.RELEASE\spring-boot-2.0.1.RELEASE.jar and still found it in it has this SpringApplication class that the JVM cannot find. I also explicitly added spring-boot-2.0.1.RELEASE.jar to the project, but the error remained the same. There is only a suspicion that I am using Open JDK, and not Oracle, which did not install on the system, but simply downloaded the deployed files and placed them in the folder I needed (the JDK installer for some reason does not work for me). Does anyone have any suggestions on what this problem may be related to?
Related
I am currently in the need to create a Spring project with Java version 8. I have set Java to the version 8 and the JDK is 1.8. However, when I build it - I got this notification
Which indeed turn my Java into 17 in my pom.xml . I tried to change the version from my pom and synced it but when I rebuild my project again I got this error
Upgrading my java version to above 8 is not an option. How to fix this?
//edit:
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>3.0.0</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</description>
<properties>
<java.version>8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Spring Boot 3.0.0 requires Java 17 and upwards to be compatible with the new features. If you really want to use Java 1.8 I would suggest downgrading the Spring Boot version to the previous stable version which is 2.7.6
I was following this guide https://www.baeldung.com/spring-data-cassandra-tutorial to try and get started with using Cassandra paired with spring boot, however, the Cassandra connector dependency:
<!-- https://mvnrepository.com/artifact/com.datastax.oss/java-driver-core -->
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.14.0</version>
</dependency>
Doesn't seem to contain the necessary modules for adding an AbstractCassandraConfiguration. When adding spring-boot-starter-data-cassandra as a dependancy it gives me the required modules to add Cassandra configurations, but my build fails with the error:
java: error reading `C:\Users\X\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar; zip END header not found`
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 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.morpheus</groupId>
<artifactId>reportdbgateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>reportdbgateway</name>
<description>Charlie's software engineering assignment cassandra db gateway</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</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>
My first approach would be going to:
C:\Users\X.m2\repository\com\google\code\findbugs\jsr305\3.0.2
and delete:
jsr305-3.0.2.jar
and then run a maven clean install or your goal
Sometimes the jars are downloaded corrupted
I have generated a spring boot application with spring-initializer. when im building the project it gives an unknown error in pom.xml file.
Why is this happening and how to reslove it?error with the 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.research</groupId>
<artifactId>patients-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>patients-api</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-data-jpa</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>
it is not an error to worry about. Spring Boot 2.1.5.RELEASE has release just a week back and probably the IDE you are using for example STS may not be the latest one.
You have 2 options:
update your IDE & Maven and to the latest version [OR]
Simply change version <version>2.1.5.RELEASE</version> to <version>2.1.4.RELEASE</version> and do a Maven update on the project.
I had a similar issue and I fixed with the above options.
Hope this helps.
I just imported a spingboot project that I created in https://start.spring.io/ in eclipse.
I tried to import two times, but the problem persists.
Already tried to do a mvn update , a mvn clean install, tried to clean the project but none of this worked.
Its a problem in the first line of pom xml file.
I dont have any idea how to solve this.
I'm using java 11
This is the complete POM 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
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.in28minutes.springboot.rest.example</groupId>
<artifactId>spring-boot-2-jpa-with-hibernate-and-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-2-jpa-with-hibernate-and-h2</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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
This seems like a bug in eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340
You can fix this by temporary downgrading the maven jar plugin version to 3.1.1 from 3.1.2. Add this to the properties section:
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
So your pom will 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>
<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.in28minutes.springboot.rest.example</groupId>
<artifactId>spring-boot-2-jpa-with-hibernate-and-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-2-jpa-with-hibernate-and-h2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
Update:
A fix has been released. Click Help > Check for updates in Eclipse/STS and install the newest m2e connector.
Step 1:
Downgrade to <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<properties>
<java.version>X</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Step 2 Update Project
Right Click on your Project
Go to Maven
Click on Update Project
Clean and Re-Run your Application
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
Add this dependency in pom.xml under properties tag
For spring boot project I have added this:
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Was Getting exact same error. Solution by Gybandi kinda worked for me.
Updating project in Maven> menu does nothing to make error icon go away.
Did the 3.1.1 and then did a maven -> update project from context menu. The red (x) icon is now GONE :-). But I really don't want to downgrade my maven plugin, if possible.
The suggestion of updating m2e-connector from eclipse marketplace
does not work. All I see against the m2e-connector entry is a "learn
more" link which takes me to its webpage. Nothing like
"upgrade/update" button present.
if you are using spring boot downgrade the version to 2.1.4.RELEASE instead of 2.1.5.RELEASE it will solve the problem
I am using eclipse photon and had similar issue. Didnt want to add the maven-jar-plugin.version in my pom as I dont want my codebase to contain code specific to IDE.
What I noticed is eclipse photon has m2e version of 1.5 which is causing the problem. I uninstall all the m2e connectors, restarted my eclipse and then installed the m2e connector using the below url manually
https://download.eclipse.org/technology/m2e/releases/1.13/
this worked like a charm
Adding packaging tag solved my problem. Didn't need to lower maven-jar plugin version.
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/>
</parent>
I fixed this issue by changing the version from 2.1.6 to 2.1.3
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I changed this to 2.1.3 because there were two versions were shown available in local m2 repository at below path
.m2\repository\org\springframework\boot\spring-boot-starter-parent
Good morning, I have a head the end of the week with an error in the project that I'm doing for the study of springboot + angular + jpa.
At the time of doing a service management class, I used it according to the tutorial of an extended class of class JpaRepository.
But a project error that I can not solve.
Follow the pom.xml and some images of the project, if anyone can help I thank you!
<?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>marco.prova</groupId>
<artifactId>apiweb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>apiweb</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.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.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.0.5.RELEASE</version>
</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>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Project images in STS.
https://uploaddeimagens.com.br/imagens/1-png-6e078f12-f26b-4266-8030-520f0f0fe7d1
https://uploaddeimagens.com.br/imagens/2-png-2224373b-2cec-46dc-b986-e68876ef57db
https://uploaddeimagens.com.br/imagens/3-png-740ac73d-5bd4-4f45-9394-c2717d4a9423
https://uploaddeimagens.com.br/imagens/4-png-9202635e-5a30-4f58-a862-70d3e9034ec6
I'm waiting! Thank you!
Or You can try to delete org.springframework.data folder from C:\Users\User\.m2 folder and update Maven project
the type
org.springframework.data.repository.query.QueryByExampleExecutor
cannot be resolved. It is indirectly referenced from required .class
files
You need to download Spring data commons jar and keep it in your classpath.
Or add the following dependency in your POM:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
You should use the spring-boot-starter-data-jpa starter instead:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>