当前位置:网站首页>@Import, conditional and @importresource annotations
@Import, conditional and @importresource annotations
2022-07-25 10:12:00 【You learned Ma today】
@Import
@Import({User.class, DBHelper.class})
@Configuration(proxyBeanMethods = false) // tell SpringBoot This is a configuration class == The configuration file
public class MyConfig {
}import Import the class of the specified type , And you can automatically create a parameterless constructor for these two components , And objects of the specified type are placed in containers
@Conditional
ctrl+h Open the inheritance tree of the annotation , There are many derived annotations

condition Translation is conditional , As the name suggests, it is to inject components through various conditions
such as ConditionOnBean, and ConditionOnMissionBean The two notes are opposite
One is if there is a Bean Then inject the current Bean, Another is that there is no one Bean Then inject the current Bean
If the annotation is written on the class name , If there are components in the container Bean Complete assembly , On the contrary, do not assemble .
Be careful :

The situation will be judged first , Because it has not been assembled into the container at the time of judgment , So two of the classes Bean All failed to assemble
@ImportResourse
We are not using springboot When developing a project , Using all of these xml Writing , To register bean, If we need to use xml The way is springboot On the project , I just need to add an annotation in config Class
@ImportResource("classpath:bean.xml")

These components are contained in the container
边栏推荐
猜你喜欢

Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (III)
![[recommended collection] with these learning methods, I joined the world's top 500 - the](/img/95/e34473a1628521d4b07e56877fcff1.png)
[recommended collection] with these learning methods, I joined the world's top 500 - the "fantastic skills and extravagance" in the Internet age

message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“

Swift creates weather app
![[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)](/img/6e/da80133e05b18c87d7167c023b6c93.gif)
[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)

小程序H5获取手机号方案

线程池的设计和原理

mysql历史数据补充新数据

阿里MQTT物联网平台“云产品流转”实战——两片ESP32通过物联网平台实现远程互操作

See how a junior student of double non-2 (0 Internship) can get an offer from Alibaba and Tencent
随机推荐
[Android studio] batch data import to Android local database
Mlx90640 infrared thermal imager temperature measurement module development notes (4)
SSM整合(简单的图书管理系统来整合SSM)
看一个双非二本(0实习)大三学生如何拿到阿里、腾讯的offer
Wechat applet jumps to other applets
阿里MQTT物联网平台“云产品流转”实战——两片ESP32通过物联网平台实现远程互操作
emmet语法速查 syntax基本语法部分
[machine translation] scones -- machine translation with multi tag tasks
多数相合问题总结
Record of deep learning segment error (segment core/ exit code 139)
js数字千位分割的常用方法
Download and installation of QT 6.2
Introduction to testbench
OC -- packaging class and processing object
用ESP32+TM1638实验NTP网络校时闹钟的ARDUINO代码
Introduction to arm GIC
Excel导入导出源码分析
Pnpm Brief
Yarn quick reference manual
小程序调起微信支付