您的位置:首页 > 编程语言 > Java开发

Spring中需要留意的几个注解

2018-12-13 10:33 330 查看

@Primary:在相同的bean中,优先选择用@Primary注解的bean(该注解写在各个bean上)

@Qualifier:在众多相同的bean中,@Qualifier指定需要注入的bean(该注解跟随在@Autowired后)
@Configuration标注在类上,相当于把该类作为spring的xml配置文件中的《beans》,作用为:配置spring容器(应用上下文)
以下两种方式等价
方式一:
ApplicationContext context = new AnnotationConfigApplicationContext(TestConfiguration.class);
方式二:
ApplicationContext context = new
ClassPathXmlApplicationContext(“spring-context.xml”);
@ApiOperation注解不是Spring的,它是swagger里的,
@ApiOperation是用来创建Api说明文档的
使用方式:
@ApiOperation(value = “接口说明”, httpMethod = “接口请求方式”, response =
“接口返回参数类型”, notes = “接口发布说明”;其他参数可参考源码;

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: