在spring3.1中怎么在annotation中注入properties中的值
在spring3.1中如何在annotation中注入properties中的值
网上搜索到的内容大多数是2010年以前的实现方案,都是自己实现的,在3.1中已经有自己的实现了,内容如下:
步骤1:在src下创建properties文件,内容如下:
spring.scheduler.cron = 0 0 0 0
步骤2:
<context:property-placeholder location="classpath:drm.properties" ignore-unresolvable="true"/>
步骤3:
private String cron = null; @Value("${spring.scheduler.cron}") public void setCron(String cron) { this.cron = cron; }