通过注解配置bean-快速入门
2025-4-20
| 2025-4-20
Words 195Read Time 1 min
type
status
date
slug
summary
tags
category
icon
password
使用注解配置bean,注解包括,@Controller,@Service,@Responsity,@Component

创建一个类,加上注解

配置文件中配置扫描路径

获取bean

从debug中可以看到beanfactory下面的singletonObject中创建的对象,可以看到,创建的对象,id是类名的第一个字母小写。
notion image
image-20230205141916186

测试获取对象,id为类名小写

notion image
image-20230205142149284
速算机器人通过属性文件给bean注入值
Loading...