SpringBoot可能碰到的注解

作者: gu_lao_rou-p 分类: springBoot 发布时间: 2022-01-03 19:51

config层用于放配置类

@ComponentScan:配置要交给Spring管理的类路径
SpringBootApplication注解包含了@ComponentScan注解
如果启动类和其它类所在的包没有包含关系的话,需要加@ComponentScan注解
注意:扫描的路径不要太通用,比如扫描”com.jiawa”,而不是”com”(会把第三方jar里的类也扫描出来)

@ComponentScan:配置要交给Spring管理的类路径

SpringBootApplication注解包含了@ComponentScan注解

如果启动类和其它类所在的包没有包含关系的话,需要加@ComponentScan注解

controller层用于定义接口,是请求的入口

@RestController注解用于声明返回文本数据,一般返回JSON
@Controller注解用于声明返回界面
@RestController = @Controller + ResponseBody


Warning: Undefined variable $aria_req in /www/wwwroot/l.lvovl.cn/wp-content/themes/JieStyle-Two-master/comments.php on line 26

Warning: Undefined variable $aria_req in /www/wwwroot/l.lvovl.cn/wp-content/themes/JieStyle-Two-master/comments.php on line 27

Warning: Undefined variable $aria_req in /www/wwwroot/l.lvovl.cn/wp-content/themes/JieStyle-Two-master/comments.php on line 28
标签云