简体   繁体   中英

“Spring Boot Project” Error: Could not find or load main class fyp.fms.FleetManagementSystemApplication

I have gone through all the articles available in and out stack over flow. But my problem is not resolved. I have a working java 8 which works fine on my all applications with in eclipse and also i have tried to run with cmd. it means class path, environment variable etc, all works fine. Now i want to create a Spring boot project, so when ever i run an spring boot project using both Run As Java Application & Spring Boot App, It Gives This Error "Error: Could not find or load main class package.classname" Here is the Screen Shot: 在此处输入图像描述

Note: I have tried almost every thing, like clean project, checking environment variables, updated eclipse etc. This problem is with only a spring boot application. All other Java applications works fine.

Here is my pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>

4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.1.RELEASE fyp fms 0.0.1-SNAPSHOT FleetManagementSystem Fleet Management System On Spring Boot. A Final Year Project.

<properties>
    <java.version>1.8</java.version>
    <start-class>fyp.fms.FleetManagementSystemApplication</start-class>
</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-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
    </plugins>
</build>
  1. Add following property to pom.xml

     <properties> <start-class>fyp.fms.FleetManagementSystemApplication</start-class> </properties>
  2. Add this build plugin if you don't have it in your pom

   <build>
          <plugins>
           <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
              <configuration>
                  <executable>true</executable>
              </configuration>
          </plugin>
          </plugins>
  </build>
  1. run mvn clean install
  2. Run application using mvn springboot:run

Can you try below steps:

Right click on your project. Select "Run As" -> "Maven build...". Then in "Goals" field, enter "spring-boot:run". Apply & Run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM