zoukankan      html  css  js  c++  java
  • Spring 中注入 properties 中的值

     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"/>
    # default.properties file content
    local.attachment.path=1
    attachment.resume.path=2
    interview.attachment.path=D:My Document
    /**
     *  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;
        }
    }
    @Resource
    private PathConfig pathConfig;
  • 相关阅读:
    sqlserver编程基本语法
    每日一记--技术小细节
    每日一记--jsp
    每日一记--session/servletContext
    每日一记--cookie
    每日一记--HashTable/HashMap/ConcurrentHashMap
    每日一记--Ajax(下)
    每日一记--Axjx
    每日一记--索引/过滤器
    每日一记--酱油日
  • 原文地址:https://www.cnblogs.com/tonycody/p/3740073.html
Copyright © 2011-2022 走看看