spring property扩展

复制代码
package com.sf.integration.ident.redis;

import java.io.IOException;
import java.util.Properties;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class SSSPropertyPlaceholderConfigurer extends
PropertyPlaceholderConfigurer {

private static Properties props;

@Override
public Properties mergeProperties() throws IOException {
props = super.mergeProperties();
Property.init(props);
return props;
}
}
复制代码

复制代码
package com.sf.integration.ident.redis;

public class Property {

    private static java.util.Properties property;

    private Property() {
    }

    static void init(java.util.Properties props) {
        property = props;
    }

    public static String getProperty(String key) {
        return property.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        return property.getProperty(key, defaultValue);
    }
}
时间: 2024-08-11 01:35:50

spring property扩展的相关文章

Spring8:一些常用的Spring Bean扩展接口

前言 Spring是一款非常强大的框架,可以说是几乎所有的企业级Java项目使用了Spring,而Bean又是Spring框架的核心. Spring框架运用了非常多的设计模式,从整体上看,它的设计严格遵循了OCP----开闭原则,即: 1.保证对修改关闭,即外部无法修改Spring整个运作的流程 2.提供对扩展开放,即可以通过继承.实现Spring提供的众多抽象类与接口来改变类加载的行为 开卷有益,阅读Spring源码(无需每个类都看得很细,大体流程能梳理出来即可)对于个人水平的提升是帮助非常大

Spring可扩展Schema标签

基于Spring可扩展Schema提供自定义配置支持 http://blog.csdn.net/cutesource/article/details/5864562 WARN : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored XML validation warning org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 66; s

基于Spring可扩展Schema自定义配置(2)

本章主要实现配置支持,注解扫描等功能.为本次教程的核心 命名空间支持 要实现命名空间支持,需要继承自NamespaceHandlerSupport. package com.codestd.spring.cxf.config.schema; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; import com.codestd.spring.cxf.config.EndpointBeanProcessor;

beetl-spring Beetl的Spring整合扩展(2):Beetl与Spring MVC整合

二.Beetl与Spring MVC整合 本章主要介绍通过beetl-spring完成Beetl与Spring MVC整合的功能.和Beetl自带的BeetlSpringViewResolver及BeetlSpringView相比,本项目提供的BeetlViewResolver增强了视图解析器的功能,使多视图解析器各自使用各自的GroupTemplate以使用不同的Beetl配置成为可能. 2.1 BeetlViewResolver BeetlViewResolver是一个Spring MVC视

Dubbo源码分析(三):自定义Schema--基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)

在很多情况下,我们需要为系统提供可配置化支持,简单的做法可以直接基于Spring的标准Bean来配置,但配置较为复杂或者需要更多丰富控制的时候,会显得非常笨拙.一般的做法会用原生态的方式去解析定义好的xml文件,然后转化为配置对象,这种方式当然可以解决所有问题,但实现起来比较繁琐,特别是是在配置非常复杂的时候,解析工作是一个不得不考虑的负担.Spring提供了可扩展Schema的支持,这是一个不错的折中方案,完成一个自定义配置一般需要以下步骤: 设计配置属性和JavaBean 编写XSD文件 编

如何进行高效的源码阅读:以Spring Cache扩展为例带你搞清楚

摘要 日常开发中,需要用到各种各样的框架来实现API.系统的构建.作为程序员,除了会使用框架还必须要了解框架工作的原理.这样可以便于我们排查问题,和自定义的扩展.那么如何去学习框架呢.通常我们通过阅读文档.查看源码,然后又很快忘记.始终不能融汇贯通.本文主要基于Spring Cache扩展为例,介绍如何进行高效的源码阅读. SpringCache的介绍 为什么以Spring Cache为例呢,原因有两个 Spring框架是web开发最常用的框架,值得开发者去阅读代码,吸收思想 缓存是企业级应用开

Spring Cache扩展:注解失效时间+主动刷新缓存

*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* BLOCKS =============================================================================*/ p, blockquote, ul, ol, dl, table, pre { margin: 15px 0; } /* HEAD

[Spring] - Property注入

使用Spring注入Properies文件方法: 1.src中新建一个settings.properties文件,内容如下: db_driverClassName=com.mysql.jdbc.Driver db_url=jdbc:mysql://127.0.0.1/test db_username=root db_password=root test_userName=Robin test_age=18 2.在spring的applicationContext.xml中加入这段: <bean

【Java】Spring MVC 扩展和SSM框架整合

开发web项目通常很多地方需要使用ajax请求来完成相应的功能,比如表单交互或者是复杂的UI设计中数据的传递等等.对于返回结果,我们一般使用JSON对象来表示,那么Spring MVC中如何处理JSON对象? JSON对象的处理 使用@ResponseBody实现数据输出 要使用JSON,所以导一下JSON工具包.JSON工具包,密码4i0l. Controller层代码示例(这里使用的是阿里巴巴的 fastjson): 1 /** 2 * 判断注册时用户编码是否唯一 3 * @param re