当前位置:网站首页>Autowired自动装配
Autowired自动装配
2022-08-04 21:39:00 【Pr Young】
自动装配本来指工业上用机器代替人,来自动的完成一些组装任务
在spring和springboot里面是指将spring容器里面的bean和需要这个bean的类,自动组装在一起
(1)引入redis的依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
(2)将RedisTemplate对象注入到Spring容器里面:
@Autowired
private RedisTemplate redisTemplate;
另一个实际的例子:
@Autowired
//自动装配
private AuthenticationManager authenticationManager;
@Override
//返回一个Map,键和值都是字符串
public Map<String, String> login(String username, String password)
{
authenticationManager.authenticate();
}
将AuthenticationManager类的对象authenticationManager注入到spring容器里面
边栏推荐
- milvus配置相关
- UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd6 in position 120: invalid continuation byte
- ES6高级-Promise的用法
- PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning Code Analysis
- "Jianzhi offer" brush title classification
- 数电快速入门(五)(编码器的介绍以及通用编码器74LS148和74LS147的介绍)
- 可视化工作流引擎开发OA系统,让企业少花冤枉钱
- 实战:10 种实现延迟任务的方法,附代码!
- SPSS-System Clustering Software Practice
- ue unreal 虚幻 高分辨率无缩放 编辑器字太小 调整编辑器整体缩放
猜你喜欢
随机推荐
Altium Designer 19.1.18 - draw polygons copper hollow out, for the cursor just capture solutions
【线性代数03】消元法展示以及AX=b的4种解情况
命名路由、组件中name的作用
DSPE-PEG-Aldehyde,DSPE-PEG-CHO,磷脂-聚乙二醇-醛基一种疏水18碳磷脂
数电快速入门(一)(BCD码和三种基本逻辑运算的介绍)
Win11如何开启Telnet客户端?
路由中的meta、params传参的一些问题(可传不可传,为空,搭配,点击传递多次参数报错)
mysql基础
七夕,当爱神丘比特遇上牛郎和织女
Data warehouse (1) What is data warehouse and what are the characteristics of data warehouse
驱动点云格式修改带来的效率提升
看看XDOC如何做Word文档预览
deepstream多相机显示布局
Some problems with passing parameters of meta and params in routing (can be passed but not passed, empty, collocation, click to pass multiple parameters to report an error)
LayaBox---TypeScript---structure
【PCBA program design】Grip dynamometer program
2022强网杯web(部分)
unity2D横版游戏教程8-音效
传奇服务器需要什么配置?传奇服务器租用价格表
ROS播包可视化