常用注解
- component
- controller(springmvc)
- service(业务层)
- repository(dao层)
引入外部properties文件
<context:property-placeholder location="classpath:database.properties"/>
通过表达式引入外部properties的键值
<property name="driver" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
从一个配置文件引入多个spring配置文件
<import resource="classpath:spring/spring-*.xml"/>
配置扫描包
<!--激活注解
扫描包是扫描该包以及子包所有
-->
<context:component-scan base-package="com.cyk.Service">
<!--这个包下面的repository这种注解不扫描-->
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
beanfactory与applicationContext的区别
参考官方文档
beanfactory是applicationContext的爷爷