================typesafeconfig的使用====================

#1、加入依赖包 config-1.2.1.jar

#2、加载配置

ConfigFactory.parseFile(new File("resource/test.conf"));

ConfigFactory.load(test)

#3、getString(key)方法获取

config1.getString("complex-app.something")

// ConfigFactory.parseString使用parseString直接解析
            Config config2 = ConfigFactory.parseString("akka.loggers =            \"akka.testkit.TestEventListener\"");
            System.out.println(config2.getString("akka.loggers"));
            
  // 使用parseString 直接解析json字符串
            Config config3 = ConfigFactory.parseString("{\"a\":\"b\", \"c\":\"d\"}");
            System.out.println(config3.getString("a"));
            System.out.println(config3.getString("c"));

#4、合并配置文件

Config firstConfig = ConfigFactory.parseFile(new File("resource/test.conf"));
            Config secondConfig =ConfigFactory.parseFile(new File("resource/test1.conf"));
            //a.withFallback(b)  a和b合并,如果有相同的key,以a为准
            Config finalConfig = firstConfig.withFallback(secondConfig);

TypeSafe Config使用的更多相关文章

  1. Java基础学习总结(66)——配置管理库typesafe.config教程

    Typesafe的Config库,纯Java写成.零外部依赖.代码精简.功能灵活.API友好.支持Java properties.JSON.JSON超集格式HOCON以及环境变量.它也是Akka的配置 ...

  2. 报错:Exception in thread "main" com.typesafe.config.ConfigException$UnresolvedSubstitution

    报错现象: 报错原因: pom文件中的jar包太高,可以降低jar包的版本号. 报错解决: 我将2.11换成了2.10,即可解决. <dependency> <groupId> ...

  3. 浅谈Slick(4)- Slick301:我的Slick开发项目设置

    前面几篇介绍里尝试了一些Slick的功能和使用方式,看来基本可以满足用scala语言进行数据库操作编程的要求,而且有些代码可以通过函数式编程模式来实现.我想,如果把Slick当作数据库操作编程主要方式 ...

  4. [翻译] AKKA笔记- ACTORSYSTEM (配置CONFIGURATION 与调度SCHEDULING) - 4(一)

    原文在http://rerun.me/2014/10/06/akka-notes-actorsystem-in-progress/ 像我们前面看到的,我们可以用ActorSystem的actorof方 ...

  5. Spark相关错误汇总

    前面介绍了Spark开发环境的搭建,下面将在实际开发过程中遇到的一些问题汇总一下: 1.Exception in thread "main" com.typesafe.config ...

  6. Spark集群 + Akka + Kafka + Scala 开发(3) : 开发一个Akka + Spark的应用

    前言 在Spark集群 + Akka + Kafka + Scala 开发(1) : 配置开发环境中,我们已经部署好了一个Spark的开发环境. 在Spark集群 + Akka + Kafka + S ...

  7. 如何通过源码生成Gatling可执行工具

    其实,这个对于不是很熟系sbt的人来说,或者对scala语言没有什么了解的人,接触Gatling这个开源的性能测试框架,还是有些茫然的. 因为GitHub上提供的Gatling (最新版本:2.2.0 ...

  8. spark下测试akka的分布式通讯功能

    采用的spark版本为1.1.0 scala版本为2.10.4 编写scala类文件myactors.scala: package bluejoe import akka.actor._ import ...

  9. akka构建简单分布式应用

    http://www.cnblogs.com/hequn/articles/3764630.html 当程序的要求达到一台计算机的极限时,我们便需要将程序分布式化,让程序运行在多台计算机上.akka提 ...

随机推荐

  1. jQuery设置 select、radio、checkbox 默认选中的值

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. Python的格式化输出,基本运算符,编码

    一. 格式化输出现在有以下需求,让用户输入name, age, job,hobby 然后输出如下所示: -----------info of Alex Li----------- Name : Ale ...

  3. 1005 Spell It Right

    1005 Spell It Right   Given a non-negative integer N, your task is to compute the sum of all the dig ...

  4. PyTorch学习笔记之n-gram模型实现

    import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as ...

  5. python学习笔记1-numpy/enumerate

    1. np.size和np.prod import numpy as np x = np.zeros((3, 5, 2), dtype=np.complex128) # ndarray.size is ...

  6. Java中判断String对象是否为空的方法

    Java原生的方法: String对象中有一个isEmpty的方法判断是否为空,其实isEmpty完全等同于string.length()==0,注意如果String本身是null,那么使用strin ...

  7. openlayer3 加载geoserver发布的WFS服务

    转自原文 openlayer3加载geoserver发布的WFS服务 openlayers3调用GeoServer发布的wfs 1 参考一 1.1 问题 openlayer3加载WFS存在跨域问题,需 ...

  8. 【spring data jpa】使用spring data jpa时,关于service层一个方法中进行【删除】和【插入】两种操作在同一个事务内处理

    场景: 现在有这么一个情况,就是在service中提供的一个方法是先将符合条件的数据全部删除,然后再将新的条件全部插入数据库中 这个场景需要保证service中执行两步 1.删除 2.插入 这两步自然 ...

  9. Linux 设备驱动开发 —— platform设备驱动应用实例解析

    前面我们已经学习了platform设备的理论知识Linux 设备驱动开发 —— platform 设备驱动 ,下面将通过一个实例来深入我们的学习. 一.platform 驱动的工作过程 platfor ...

  10. stateMachine 相关知识

    一个state的基本构造,processMessage 以及可选的enter exit 和getName. processMessager是用于处理数据. enter 和exit 则是类似于 面向编程 ...