[英]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.