查看“Spring Boot 常见注解”的源代码
←
Spring Boot 常见注解
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看和复制此页面的源代码。
=== spring-boot-autoconfigure-x.x.x.RELEASE.jar === ==== @SpringBootApplication ==== 来自 spring-boot-autoconfigure-x.x.x.RELEASE.jar https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/using-boot-using-springbootapplication-annotation.html 表示一个配置类,声明一个或多个@Bean 方法,同时触发自动配置和组件扫描。 这是一个方便的注解,相当于声明@Configuration、@EnableAutoConfiguration 和 @ComponentScan。 ==== @EnableAutoConfiguration ==== 来自 spring-boot-autoconfigure-x.x.x.RELEASE.jar https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/api/index.html?org/springframework/boot/autoconfigure/condition/ConditionalOnClass.html 启用 Spring Application Context 的自动配置,尝试猜测和配置您可能需要的 beans。 ==== @ConditionalOnClass ==== 来自 spring-boot-autoconfigure-x.x.x.RELEASE.jar https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/api/index.html?org/springframework/boot/autoconfigure/condition/ConditionalOnClass.html 只有当指定的类在类路径上时才匹配。 ==== @ConditionalOnMissingBean ==== 来自 spring-boot-autoconfigure-x.x.x.RELEASE.jar https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/api/index.html?org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBean.html 仅当指定的 bean 类和/或名称尚未包含在 BeanFactory 中时才匹配。 ==== @ConditionalOnProperty ==== https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/api/index.html?org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBean.html 条件检查指定的属性是否具有特定值。 默认情况下,属性必须存在于环境中并且不等于 false。 havingValue() 和 matchIfMissing() 属性允许进一步定制。 === spring-context-x.x.x.RELEASE.jar === ==== @Configuration ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/Configuration.html 指示一个类声明一个或多个@Bean 方法,并且可以由 Spring 容器处理以在运行时为这些 bean 生成 bean 定义和服务请求 ==== @ComponentScan ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ComponentScan.html 配置组件扫描指令以与 @Configuration 类一起使用。 提供与 Spring XML 的 <context:component-scan> 元素并行的支持。 ==== @Component ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/stereotype/Component.html 指示带注释的类是“组件”。 当使用基于注解的配置和类路径扫描时,这些类被认为是自动检测的候选者。 ==== @Service ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/stereotype/Service.html 表示带注释的类是“服务”,最初由领域驱动设计(Evans,2003)定义为“作为模型中独立的接口提供的操作,没有封装状态”。 也可能表明一个类是“业务服务外观”(在核心 J2EE 模式意义上),或类似的东西。 此注释用作 @Component 的特化,允许通过类路径扫描自动检测实现类。 ==== @Bean ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch02s02.html @Bean 是一个方法级注释,是 XML <bean/> 元素的直接模拟。 ==== @Conditional ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/5.3.1/javadoc-api/ 表示组件只有在所有指定条件都匹配时才有资格注册。 可以是 bean 从定义到注册之前以编程方式确定的任何状态。 如果 @Configuration 类标有 @Conditional,则与该类关联的所有@Bean 方法、@Import 注释和@ComponentScan 注释都将受制于条件。 ==== @Controller ==== 来自 spring-context-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/stereotype/Controller.html 指示带注释的类是“控制器”(例如 Web 控制器)。 此注释用作 @Component 的特化,允许通过类路径扫描自动检测实现类。 它通常与基于 RequestMapping 注释的注释处理程序方法结合使用。 === spring-web-x.x.x.RELEASE.jar === ==== @ResponseBody ==== 来自 spring-web-x.x.x.RELEASE.jar https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/ResponseBody.html 指示方法返回值应绑定到 Web 响应正文的注释。 支持带注释的处理程序方法。 从 4.0 版开始,这个注释也可以添加到类型级别,在这种情况下它是继承的,不需要添加到方法级别。
返回至
Spring Boot 常见注解
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
Spring Boot 2 零基础入门
Spring Cloud
Spring Boot
设计模式之禅
VUE
Vuex
Maven
算法
技能树
Wireshark
IntelliJ IDEA
ElasticSearch
VirtualBox
软考
正则表达式
程序员精讲
软件设计师精讲
初级程序员 历年真题
C
SQL
Java
FFmpeg
Redis
Kafka
MySQL
Spring
Docker
JMeter
Apache
Linux
Windows
Git
ZooKeeper
设计模式
Python
MyBatis
软件
数学
PHP
IntelliJ IDEA
CS基础知识
网络
项目
未分类
MediaWiki
镜像
问题
健身
国债
英语
烹饪
常见术语
MediaWiki帮助
工具
链入页面
相关更改
特殊页面
页面信息