Spring Boot常用注解类

常用注解类

packge org.springframework.boot.autoconfigure

@EnableAutoConfiguration

Enable auto-configuration of the Spring Application Context, attempting to guess and configure beans that you are likely to need. Auto-configuration classes are usually applied based on your classpath and what beans you have defined. For example, if you have tomcat-embedded.jar on your classpath you are likely to want a TomcatServletWebServerFactory (unless you have defined your own ServletWebServerFactory bean).

@EnableAutoConfiguration用于开启Spring应用上下文的自动配置,尝试猜测并配置你可能需要的beans。哪些自动配置类的会被采用,通常基于你的classpath和你定义的beans。例如,如果你的classpath有tocat-embedded.jar,你可能需要一个TomcatServletWebServerFactory (除非你已定义了自己的ServletWebServerFactory bean)

When using @SpringBootApplication, the auto-configuration of the context is automatically enabled and adding this annotation has therefore no additional effect.

当使用@SpringBootApplication,上下文的自动配置就自动启用了,这时添加@EnableAutoConfiguration不会有额外的影响。
Auto-configuration tries to be as intelligent as possible and will back-away as you define more of your own configuration. You can always manually exclude() any configuration that you never want to apply (use excludeName() if you don't have access to them). You can also exclude them via the spring.autoconfigure.exclude property. Auto-configuration is always applied after user-defined beans have been registered.

自动配置力求尽可能地智能,当你定义了更多的自己的配置,相关的自动配置就会减少。你可以手动排除你不想使用的配置(使用excludeName(), 如果你不需要访问它们)你也可以用spring.autoconfigure.exclude属性来排除不需要的配置。自动配置总是在用户定义的beans注册后被调用。
The package of the class that is annotated with @EnableAutoConfiguration, usually via @SpringBootApplication, has specific significance and is often used as a 'default'. For example, it will be used when scanning for @Entity classes. It is generally recommended that you place @EnableAutoConfiguration (if you're not using @SpringBootApplication) in a root package so that all sub-packages and classes can be searched.
Auto-configuration classes are regular Spring @Configuration beans. They are located using the SpringFactoriesLoader mechanism (keyed against this class). Generally auto-configuration beans are @Conditional beans (most often using @ConditionalOnClass and @ConditionalOnMissingBean annotations).

使用@EnableAutoConfiguration注解的类所在的包,通常使用@SpringBootApplication,有特别的意义且经常作为default包。例如,扫描的时候默认扫描default包下面的Entity。通常建议把@EnableAutoConfiguration放在根包里,以便所有的子包和类可以被搜索到。Auto-configuration类是常规的Spring @Configuration beans。自动配置类采用SpringFactoriesLoader加载。通常自动配置beans就是@Conditional Beans。(最常用的是@ConditionalOnClass, @ConditionalOnMissingBean)

@SpringBootApplication

Indicates a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning. This is a convenience annotation that is equivalent to declaring @Configuration, @EnableAutoConfiguration and @ComponentScan.

@SpringBootApplication表示一个配置类,该类声明一个或多个@Bean方法并且触发自动配置和组件扫描。使用一个@SpringBootApplication和同时使用@Configuration、@EnableAutoConfiguration、@ComponentScan是等效的。

@Import

Indicates one or more component classes to import — typically @Configuration classes.
Provides functionality equivalent to the <import/> element in Spring XML. Allows for importing @Configuration classes, ImportSelector and ImportBeanDefinitionRegistrar implementations, as well as regular component classes (as of 4.2; analogous to AnnotationConfigApplicationContext.register).

@Import指示导入一个或多个组件类----通常是@Configuration类。和Spring xml文件里的<import/>标签等价。可以导入@Configruation类、ImportSelector和ImportBeanDefinitionRegistrar的实现,以及常规的组件类。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/44603.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

集创北方ICN6202 低功耗MIPIDSI转2 PORT LVDS 支持1080P分辨率,成熟批量产品

ICN6202描述&#xff1a; ICN6202是一个接收MIPIDSI输入和发送LVDS输出的桥接芯片。MIPIDSI最多支持4个车道&#xff0c;每个车道的最大运行频率为1Gbps&#xff1b;总最大输入带宽为4Gbps&#xff1b;并且还支持MIPI定义的ULPS&#xff08;超低功耗状态&#xff09;。ICN6202…

Elasticsearch集群搭建

集群概念 在单台 ES 服务器上&#xff0c;随着一个索引内数据的增多&#xff0c;会产生存储、效 率、安全等问题。 因此引入集群 我们需要将索引拆分成多份&#xff0c;分别放入不同的服务器中&#xff0c;此时这几台服务器维护了同一个索引&#xff0c;我们称这几台服务器为一…

计算机毕业设计Python深度学习游戏推荐系统 Django PySpark游戏可视化 游戏数据分析 游戏爬虫 Scrapy 机器学习 人工智能 大数据毕设

本论文的主要研究内容如下&#xff1a; 了解基于Spark的TapTap游戏数据分析系统的基本架构&#xff0c;掌握系统的开发方法&#xff0c;包括系统开发基本流程、开发环境的搭建、测试与运行等。 主要功能如下&#xff1a; &#xff08;1&#xff09;用户管理模块&#xff1a…

vue3 JS 调用 Android 原生方法

在Vue 3中调用Android原生方法通常涉及到WebView与原生代码的交互。你可以使用WebView的JavaScript接口来实现这一点。以下是一个简化的步骤和示例代码&#xff1a; 在Android端&#xff0c;创建一个类继承自WebView并实现JavaScriptInterface。在这个类中&#xff0c;定义一个…

初阶数据结构—排序

第一章&#xff1a;排序的概念及其运用 1.1 排序的概念 排序&#xff1a;所谓排序&#xff0c;就是使一串记录&#xff0c;按照其中的某个或某些关键字的大小&#xff0c;递增或递减的排列起来的操作。 稳定性&#xff1a;假定在待排序的记录序列中&#xff0c;存在多个具有…

LIO-SAM编译ubuntu20.04 Noetic

一、下载 mkdir -p ~/lio_sam_ws/src cd ~/lio_sam_ws/src git clone https://github.com/TixiaoShan/LIO-SAM.git cd ..二、编译&&解决报错 catkin_make报错如下 解决方案&#xff1a; 第一步&#xff1a; sudo add-apt-repository ppa:borglab/gtsam-release-4…

云端墨迹:在iCloud上构筑您的个人博客或网站内容存储堡垒

云端墨迹&#xff1a;在iCloud上构筑您的个人博客或网站内容存储堡垒 在数字化时代&#xff0c;个人博客和网站成为表达思想、分享知识和展示创意的重要平台。iCloud作为苹果公司提供的云服务&#xff0c;提供了一个安全、可靠且易于使用的存储解决方案&#xff0c;让您可以在…

数学建模美赛经验小结

图片资料来自网络所听讲座&#xff0c;感谢分享&#xff01;

网络编程的学习之udp

Udp编程过程 Sento不会阻塞 实现聊天室效果 上线 聊天 下线 服务端需要一个地址&#xff0c;去保留名字和ip地址 交互的时候发结构体 下面这个宏只能在c语言里使用 ser.sin_port htons(50000); 上面是端口号50000以上&#xff0c;两边要一样 这里是不要让udp发的太快&am…

CleanCode、安全编码规范

Clean Code 规范 Clean Code 是由 Robert C. Martin 提出的编写高质量代码的原则。主要包括以下几点 有意义的命名&#xff1a; 命名要准确和清晰&#xff0c;让人一看就知道变量、函数或类的用途。避免使用缩写和难以理解的名称 // 不好的命名 val d: Int 5// 好的命名 v…

顺序结构 ( 三 ) —— 常量和变量 【互三互三】

常量 一、常量概述 常量是指在程序中使用的一些具体的数、字符。在程序运行过程中&#xff0c;其值不能被更改。如123,145.88,m,TRUE等。 1、整型常量&#xff1a;如3、-5、0等。 整型常量是表示整数的常量。有三种表示形式&#xff1a; 1&#xff09;十进制形式。如9…

Unity Shader学习笔记

Shader类型 类型详情Standard Surface Shader标准表面着色器&#xff0c;基于物理的着色系统&#xff0c;用于模拟各种材质效果&#xff0c;如石头、木材、玻璃、塑料和金属等。Unlit Shader最简单的着色器&#xff0c;不包含光照但包含雾效&#xff0c;只由最基础的Vertex Sh…

【Vision Pro开发】小白开发如何过渡到visionOS开发 - SOP清单

为什么Unity开发者应该考虑学习Vision OS的原生开发,并解释了开发过程中面临的挑战和优势。我整理了一些关键点,对于刚进入这个赛道的小白开发者可以参考: 1. Vision Pro开发平台选择 - 主要有三种选择:原生开发(Xcode+SwiftUI+RealityKit)、Unity开发和WebXR开发 - 原生开…

30. 梯度下降法及其应用

1. 引言 在深度学习中&#xff0c;损失函数的求解是一个关键步骤。损失函数通常没有解析解&#xff0c;因此需要通过最优化算法来逼近求解。其中&#xff0c;梯度下降法是最常用的优化算法之一。本文将详细介绍梯度下降法的基本概念、理论基础、及其在深度学习中的应用。 2. …

甄选范文“论基于构件的软件开发方法及其应用”,软考高级论文,系统架构设计师论文

论文真题 基于构作的软件开发 (Component-Based Software Development,CBSD) 是一种基于分布对象技术、强调通过可复用构件设计与构造软件系统的软件复用途径。基于构件的软件系统中的构件可以是COTS (Commercial-Off-the-Shelf)构件,也可以是通过其它途径获得的构件(如自…

命名空间知识点

命名空间基本概念 概念 命名空间是用来组织和重用代码的。 作用 就像是一个工具包&#xff0c;类就像是一件一件的工具&#xff0c;都是申明在命名空间中的。 命名空间的使用 基本语法 namespace 命名空间名 { 类 类 } namespace MyGame {class GameObject{} }namesp…

2970.力扣每日一题7/10 Java(暴力枚举)

博客主页&#xff1a;音符犹如代码系列专栏&#xff1a;算法练习关注博主&#xff0c;后期持续更新系列文章如果有错误感谢请大家批评指出&#xff0c;及时修改感谢大家点赞&#x1f44d;收藏⭐评论✍ 目录 解题思路 解题方法 时间复杂度 空间复杂度 Code 解题思路 incre…

图论---无向图中国邮路的实现

开始编程前分析设计思路和程序的整体的框架&#xff0c;以及作为数学问题的性质&#xff1a; 程序流程图&#xff1a; 数学原理&#xff1a; 本质上是找到一条欧拉回路&#xff0c;考虑图中的边权重、顶点的度数以及如何通过添加最少的额外边来构造欧拉回路&#xff0c;涉及到欧…

完善kobj_type结构体

1、实现kobj_type的release函数 #include<linux/module.h> #include<linux/init.h> #include<linux/kernel.h> #include<linux/kobject.h> #include<linux/slab.h>static void dynamic_kobj_release(struct kobject *kobj); struct my_kobject …

链表 OJ(一)

移除链表元素 题目连接&#xff1a; https://leetcode.cn/problems/remove-linked-list-elements/description/ 使用双指针法&#xff0c;开始时&#xff0c;一个指针指向头节点&#xff0c;另一个指针指向头节点的下一个结点&#xff0c;然后开始遍历链表删除结点。 这里要注…