- 浏览: 3366583 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
http://www.oschina.net/code/snippet_1760858_54923
jdbc.properties
Main-测试
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:annotation-config></context:annotation-config> <context:component-scan base-package="annotation.*" > <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> </context:component-scan> <!-- <context:property-placeholder location="classpath:/readProperties/jdbc.properties"/> --> <bean id="propertyConfigurer" class="readProperties.com.util.PropertyUtil"> <property name="location" value="classpath:/readProperties/jdbc.properties"/> </bean> </beans> <!-- 配置多个文件读取方式 --> <!-- <bean id="propertyConfigurer" class="com.common.util.PropertyUtil"> --> <!-- <property name="locations"> --> <!-- <list> --> <!-- <value>classpath*:/jdbc.properties</value> --> <!-- <value>classpath*:/url.properties</value> --> <!-- <value>classpath*:/sms.properties</value> --> <!-- <value>classpath*:/email.properties</value> --> <!-- </list> --> <!-- </property> --> <!-- </bean> -->
jdbc.properties
connection.driverclass=com.mysql.jdbc.Driver ##connection.url=jdbc\:mysql\://10.142.12.208\:3306/InvFinAdmin?useUnicode\=true&characterEncoding\=UTF-8 connection.url=jdbc\:mysql\://127.0.0.1\:3306/play?useUnicode\=true&characterEncoding\=UTF-8 connection.username=root ##connection.password=2a4c094bbb588e8169 connection.password=123456 connection.initialPoolSize=5 connection.minPoolSize=2 connection.maxPoolSize=10
package readProperties.com.util; import java.util.HashMap; import java.util.Map; import java.util.Properties; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; public class PropertyUtil extends PropertyPlaceholderConfigurer{ public static Map<String, Object> ctxPropertiesMap; @Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException { super.processProperties(beanFactoryToProcess, props); ctxPropertiesMap = new HashMap<String, Object>(); for (Object key : props.keySet()) { String keyStr = key.toString(); String value = props.getProperty(keyStr); ctxPropertiesMap.put(keyStr, value); } } public static Object getContextProperty(String name) { return ctxPropertiesMap.get(name); } }
Main-测试
package readProperties; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import readProperties.com.util.PropertyUtil; public class TestReadProperties { @Test public void testReadProperties(){ ApplicationContext ctx=new ClassPathXmlApplicationContext("classpath:readProperties/read-properties-spring-config.xml"); System.out.println("--------------"); for(String key: PropertyUtil.ctxPropertiesMap.keySet()){ System.out.println("key=="+key+"---value:"+PropertyUtil.ctxPropertiesMap.get(key)); } } }
发表评论
-
Spring Boot 属性配置
2016-06-24 11:04 1149Spring Boot 属性配置和使用 http://blog ... -
Spring Boot 集成MyBatis
2016-06-24 10:55 1990Spring Boot 集成MyBatis http://bl ... -
Spring MVC防重复提交
2016-06-17 15:47 1590http://my.oschina.net/zyqjustin ... -
Spring容器加载完之后执行特定任务
2016-06-17 15:36 2243http://my.oschina.net/simpleton ... -
使用spring-session和shiro来代理session的配置
2016-06-16 11:21 11993使用spring-session和redis来代理sessio ... -
JSTL 的 if else : 有 c:if 没有 else 的处理
2016-06-14 09:52 1294http://blog.csdn.net/xiyuan1999 ... -
spring mvc 请求转发和重定向
2016-06-14 09:48 1353http://blog.csdn.net/jackpk/art ... -
mvc:view-controller
2016-05-18 10:26 1050http://blog.csdn.net/lzwglory/a ... -
spring配置事物的方式:注解和aop配置
2016-05-14 00:26 4063参考: Spring AOP中pointcut express ... -
分布式任务调度组件 Uncode-Schedule
2016-05-13 14:47 2243http://www.oschina.net/p/uncode ... -
Mybatis分库分表扩展插件
2016-05-12 15:47 1588http://fangjialong.iteye.com/bl ... -
spring+mybatis+atomikos 实现JTA事务
2016-05-11 22:00 5475sping配置多个数据源 不同用户操作不同数据库 http:/ ... -
Spring中使用注解 @Scheduled执行定时任务
2016-05-10 09:39 1536原文:http://dwf07223.blog.51cto.c ... -
Spring中配置Websocket
2016-05-05 16:55 1246spring+websocket整合(springMVC+sp ... -
redis 集群中Session解决方案之Spring Session
2016-05-04 08:54 1275集群中Session解决方案之Spring Session h ... -
使用Spring-data进行Redis操作
2016-05-04 08:54 4735使用Spring-data进行Redis操作 http://z ... -
Spring4新特性——集成Bean Validation 1.1(JSR-349)到SpringMVC
2016-05-03 13:35 1032Spring4新特性——集成Bean Validation 1 ... -
SpringMVC介绍之Validation
2016-05-03 13:10 954SpringMVC介绍之Validation http://h ... -
spring 注解方式下使用commons-validator 验证表单
2016-05-03 11:08 3039原文: http://www.programgo.com/ar ... -
Spring MVC学习详解
2016-04-28 09:13 967原文 http://blog.csdn.net/alsocod ...
相关推荐
spring读取properties.
Spring 读取properties文件key+value方式.rar
spring读取properties配置文件的key值。
NULL 博文链接:https://nannan408.iteye.com/blog/2256177
主要介绍了spring无法读取properties文件数据问题详解,需要的朋友可以参考下
主要介绍了Spring用代码来读取properties文件实例解析,具有一定借鉴价值,需要的朋友可以参考下
主要介绍了Spring中属性文件properties的读取与使用详解的相关资料,需要的朋友可以参考下
主要介绍了在SpringBoot下读取自定义properties配置文件的方法,文中涉及到了Spring-boot中读取config配置文件的两种方式,需要的朋友可以参考下
Spring配置文件中注册三种数据源及从属性文件中读取DB连接四要素
今天小编就为大家分享一篇关于Spring加载配置和读取多个Properties文件的讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
之前的系统用的是Spring框架,国际化还是比较简单的。但是有一些提示是写在js文件里面的,搜了一些,发现一个js国际化的框架jquery.i18n.properties.js,用了一些还是比较方便的。
本篇文章主要介绍了Spring中配置和读取多个Properties文件的方式方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
主要介绍了Spring Boot的properties配置文件读取,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
1、在maven工程导入spring坐标 2、dao层的内容与结构 接口 实现类 3、server层的内容与结构 4、创建properties文件 5、配置文件样式 标签头代码:
properties_read_demo.zip
背景在 Spring 项目中,你可能需要从 properties 文件中读入配置注入到 bean 中,例如数据库连接信息,redis server的地址端口信息
osgi多个bundle之间读取同一配置文件,需要单独添加一个用来读取配置文件的bundle
read-properties:Github操作读取Java属性文件
springboot读取配置文件.rar springboot读取配置文件.rar springboot读取配置文件.rar
1.27 Spring Boot环境变量读取和属性对象的绑定 1.28 Spring Boot使用自定义的properties 1.29 改变自动扫描的包 1.30 Spring Boot Junit单元测试 1.31 SpringBoot启动时的Banner设置 1.32 Spring boot 文件上传(多...