简体   繁体   English

为什么我收到错误“默认包中的 Spring Boot 应用程序”

[英]Why I get error “Spring Boot Application in the default package”

I creaeted this class:我创建了这个 class:

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;

@SpringBootApplication
public class BootApplication {
}

on BootApplication I get the error:在 BootApplication 我收到错误:

Spring Boot Application in the default package

Any idea why I get the error above?知道为什么我会收到上述错误吗?

Declare your spring boot application in a package, default package is generally discouraged and should be avoided.在 package 中声明您的 spring 引导应用程序,默认 package 通常是不鼓励的,应该避免使用。

It can cause particular problems for spring boot applications that use @ComponentScan or @SpringBootApplication annotations.对于使用 @ComponentScan 或 @SpringBootApplication 注释的 spring 引导应用程序,它可能会导致特定问题。

Did you kept this class in a package?您是否将这个 class 保存在 package 中?

If not, please create a package, and keep the class inside it.如果没有,请创建一个 package,并将 class 保留在其中。

Also, put a main method in it.另外,在其中放置一个主要方法。

public static void main(String[] args) {
    SpringApplication.run(BootApplication.class, args);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我在运行简单的 Spring Boot 应用程序时总是得到状态为“404”的 Whitelabel 错误页面 - Why do I always get Whitelabel Error Page with status "404" while running a simple Spring Boot Application "为什么在启动 Spring Boot 应用程序时出现 Gson builder 错误?" - Why do I get Gson builder error when starting a Spring Boot application? Application.java 包中的 Spring 启动错误 - Spring boot error in Application.java package spring 启动应用程序运行,但我在 web 浏览器中收到错误 404 - spring boot application run, but I get error 404 in the web browser 为什么 Spring 引导不从默认的 application.properties 文件中读取 - Why is Spring Boot not reading from default application.properties file Spring Boot 应用程序失败 - 错误 java 包不存在 - Spring Boot application failure - Error java package does not exist Spring Boot应用程序错误 - Spring Boot Application Error 为什么我无法在 Spring 引导应用程序中使用 @Getter 和 @Setter 注释访问 get 和 set 方法? || 龙目岛 - why I am not able to access the get and set method using @Getter and @Setter Annotation in Spring Boot Application? || Lombok 为什么如果我从 IDE (Eclipse) 将 Spring Boot 应用程序作为 Java 应用程序启动它可以工作,但是当我从 CMD 启动它时,它会出现白标错误? - Why if I start a spring boot app as Java Application from the IDE (Eclipse) it works but when I start it from CMD it get me Whitelabel Error? 为什么我尝试在 Spring Boot 应用程序中使用准备好的语句执行 JdbcTemplate 查询时出现此错误? - Why am I obtaining this error trying to perform JdbcTemplate query using prepared statement in a Spring Boot application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM