# Annotation
# Parameter
# @Value
<bean id="dataSource">
<property name="url" value="${jdbc.url}" />
</bean>
对应注解
@Value("${jdbc.driver}")
private String driver;
# @PropertySource
Spring中property-placeholder的使用与解析 (opens new window)
context:property-placeholder 的注解
@PropertySource("classpath:redis.properties")
public class test {
}
# @Bean
@Configuration的使用 (opens new window)
管理 Bean 分为两个部分,一个是注册 Bean,一个装配 Bean。
完成这两个动作有三种方式,一种是使用自动配置的方式、一种是使用 JavaConfig 的方式,一种就是使用 XML 配置的方式。
自动配置:@Component + @AutoWired
JavaConfig:@Configuration + @Bean