spring 模拟试卷
Spring配置方式专项测试
- XML配置方式
- 注解配置方式
- Java配置类
- 配置方式对比与选择
- Spring Boot自动配置基础
试卷习题(13 题)
参考答案在文末判断题
1
判断题
Spring XML配置可以通过引入不同的命名空间(如context、aop、tx)来扩展配置功能。
2
判断题
在Java配置类中使用@ComponentScan注解可以实现与XML中context:component-scan相同的组件扫描功能。
3
判断题
使用@Component等注解定义Bean时,必须配置组件扫描(component-scan)才能让Spring识别并注册。
单选题
4
单选题
@Configuration注解的作用是?
5
单选题
@Component注解的作用是?
6
单选题
Spring XML配置文件中,定义Bean使用的标签是?
7
单选题
关于@Bean注解的方法调用,以下说法正确的是?
多选题
8
多选题
@Bean注解支持以下哪些属性配置?
9
多选题
以下哪些注解会被context:component-scan扫描并注册为Bean?
10
多选题
关于Spring三种配置方式的对比,以下说法正确的是?
填空题
11
填空题
定义Bean使用等注解;注入依赖使用;解决多Bean冲突使用;指定首选Bean使用@Primary。
12
填空题
在XML中启用组件扫描使用标签,通过属性指定扫描的包路径;启用注解驱动使用标签。
13
填空题
Java配置核心注解:标注配置类,定义Bean,启用组件扫描,@Import导入其他配置类。
参考答案
1.正确
2.正确
3.正确
4.A
5.B
6.B
7.B
8.A;B;C;D
9.A;B;C;D
10.A;B;C;D
11.@Component;@Autowired;@Qualifier
12.context:component-scan;base-package;context:annotation-config
13.@Configuration;@Bean;@ComponentScan
