Ch02 Annotation
Yang Haoran 7/25/2019 SpringJava
# Annotation

<context:annotation-config></context:annotation-config>
<context:component-scan base-package="com.yang.pojo"></context:component-scan>
1
2
3
2
3

可以使用value指定bean的名字,否则取第一个字母小写的类名)
步骤:
- 先在要创建bean的class里加入注解:括号里为bean的id

- 配置文件:要使用到context命名空间,扫描包内所有的class
可以使用属性resource-pattern来指定扫描的资源,如resource-pattern = “repository/*.class”表示只扫描repository下面的包





# 引入外部文件

# Spel表达式
