我有个spring boot项目,可以正常启动的。启动类有AClass修改成BClass后,启动报错: 错误: 找不到或无法加载主类

  • 作者: 凯哥Java(公众号:凯哥Java)
  • 工作小总结
  • 时间:2024-06-15 17:16
  • 654人已阅读
简介 2.检查项目配置确保你的项目配置文件(如pom.xml或build.gradle)中正确指定了主类。例如,在pom.xml中:<build>    <plugins>        <plugin>    

🔔🔔🔔好消息!好消息!🔔🔔🔔

有需要的朋友👉:联系凯哥 微信号 kaigejava2022

2. 检查项目配置

确保你的项目配置文件(如 pom.xmlbuild.gradle)中正确指定了主类。例如,在 pom.xml 中:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.example.BClass</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

检查 IDE 配置

如果你使用的是 IDE(如 IntelliJ IDEA 或 Eclipse),确保你在 IDE 中更新了启动配置,指定正确的主类。

在 IntelliJ IDEA 中,可以通过以下步骤检查:

  1. 打开 Run/Debug Configurations

  2. 确认 Main class 设置为 com.example.BClass


TopTop