springboot怎么指定启动类

1099
2024/5/18 14:18:21
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

要指定Spring Boot应用程序的启动类,可以通过在@SpringBootApplication注解中添加scanBasePackages属性来指定启动类的包路径。例如:

@SpringBootApplication(scanBasePackages = "com.example.myapp")
public class MySpringBootApplication {
    public static void main(String[] args) {
        SpringApplication.run(MySpringBootApplication.class, args);
    }
}

在上面的例子中,MySpringBootApplication类被指定为应用程序的启动类,并且该类所在的包路径为com.example.myapp。这样Spring Boot就会在该包路径下扫描并加载所有的组件。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: springboot多线程返回值怎么获取