码迷,mamicode.com
首页 > 编程语言 > 详细

Spring 中注入 properties 中的值

时间:2014-05-21 19:56:56      阅读:485      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   c   code   java   

bubuko.com,布布扣
 1 <bean id="ckcPlaceholderProperties" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
 2         <property name="locations">
 3             <list>
 4                 <value>classpath:default.properties</value>
 5             </list>
 6         </property>
 7         <property name="order" value="2"></property>
 8         <property name="ignoreUnresolvablePlaceholders" value="true" />
 9 </bean>
10 <bean id="pathConfig" class="com.movitech.erms.business.configuration.PathConfig"/>
bubuko.com,布布扣
# default.properties file content
local.attachment.path=1
attachment.resume.path=2
interview.attachment.path=D:\My Document
bubuko.com,布布扣
/**
 *  PathConfig 注入的类文件
 *
 * @author Tony.Wang
 * @time 2014/4/28 0028 17:31
 */
public class PathConfig {

    @Value("${local.attachment.path}")
    private String localAttachmentPath;

    @Value("${attachment.resume.path}")
    private String attachmentResumePath;

    @Value("${interview.attachment.path}")
    private String interviewAttachmentPath;

    public String getLocalAttachmentPath() {
        return localAttachmentPath;
    }

    public String getInterviewAttachmentPath() {
        return interviewAttachmentPath;
    }

    public String getAttachmentResumePath() {
        return attachmentResumePath;
    }
}
bubuko.com,布布扣
@Resource
private PathConfig pathConfig;

 

Spring 中注入 properties 中的值,布布扣,bubuko.com

Spring 中注入 properties 中的值

标签:style   blog   class   c   code   java   

原文地址:http://www.cnblogs.com/tonycody/p/3740073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!