当前位置: 代码迷 >> Web前端 >> 在spring3.1中怎么在annotation中注入properties中的值
  详细解决方案

在spring3.1中怎么在annotation中注入properties中的值

热度:460   发布时间:2013-12-19 00:33:34.0
在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;
	}

?

  相关解决方案