2. 检查项目配置
确保你的项目配置文件(如 pom.xml
或 build.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 中,可以通过以下步骤检查:
打开
Run/Debug Configurations
。确认
Main class
设置为com.example.BClass