[email protected]
这个注解写在某个类上,说明这个类是主配置类,SpringBoot通过运行这个类的main方法来启动SpringBoot应用。

2.按住ctrl,点击@SpringBootApplication这个注解, 发现这个注解是由很多注解组合而成的。

SpringBoot注解

(1)@SpringBootConfiguration

这个注解标注在类上,表示这个类是SpringBoot的配置类。配置类和以前用Spring的时候那些配置文件是一样的。

(2)@EnableAutoConfiguration

开启自动配置,开启后配置才能生效。

[email protected]

加在类上,表示这个类的所有方法返回的数据都可以直接写给浏览器,如果是对象,转成json数据

加在方法上,表示这个方法的返回数据写给浏览器。

@ResponseBody和@Controller这两个注解可以用一个@RestController来代替

相关文章:

  • 2022-12-23
  • 2021-11-19
猜你喜欢
  • 2021-07-19
  • 2021-10-08
  • 2022-01-10
  • 2021-12-31
  • 2021-05-19
  • 2021-12-09
相关资源
相似解决方案