3 SpringBoot的启动方式

第一种:

在控制器配置EnableAutoConfiguration并使用SpringApplication启动程序

第二种【常用】

创建一个App类,在App类中配置EnableAutoConfiguration和组件扫描ComponentScan,

然后使用SpringApplication启动程序,这样就可以访问多个Controller了

创建一个User控制器

public User userInfo(@PathVariable(value="id")Integer id){
    User user = new User("gyf","123");
    return user
}

创建APP类

猜你喜欢

转载自blog.csdn.net/qq_43674132/article/details/92802981