I created a project with Spring Initializr in Maven, Java 17, Spring boot 3.0.0 with two dependencies : Spring Web and Spring Boot DevTools
i tried to run the main class and i have this error :
Erreur : impossible to find or charge the principal class src.main.java.com.packt.cardatabase.CardatabaseApplication caused by : java.lang.ClassNotFoundException: src.main.java.com.packt.cardatabase.CardatabaseApplication
I did change nothing in the code can you explain me the error please thanks you very much
CardatabaseApplication.java :
package com.packt.cardatabase;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CardatabaseApplication {
public static void main(String[] args) {
SpringApplication.run(CardatabaseApplication.class, args);
}
}
" Now, if the project was executed correctly, you should see the started CardatabaseApplication class in the text at the end of the console. The following screenshot shows the content of the Eclipse console after our Spring Boot project has been started: "
CodePudding user response:
Two things indicate to the real issue:
- The class
CardatabaseApplication
is defined in thecom.packt.cardatabase
database. - This error message
java.lang.ClassNotFoundException: src.main.java.com.packt.cardatabase.CardatabaseApplication
.
Somehow, you need to remove src.main.java
when you are running the class. I assume you are running this from your IDE, and a misconfiguration is causing this.
CodePudding user response:
https://i.stack.imgur.com/qBt1h.png
That is the screen of my IDE tell me what do you wanna see i screen again