properties

SpringBoot自学教程 | 第二篇:Spring Boot配置文件详解

不问归期 提交于 2020-02-15 15:23:15
  在一般情况下,我们不需要做太多的配置就能够让spring boot正常运行。在一些特殊的情况下,我们需要做修改一些配置,或者需要有自己的配置属性。   一、自定义属性     当我们创建一个springboot项目的时候,系统默认会为我们在src/main/java/resources目录下创建一个application.properties。个人习惯,我会将application.properties改为application.yml文件,两种文件格式都支持。     在application.yml自定义一组属性: 1 my: 2 name: forezp 3 age: 12     如果你需要读取配置文件的值只需要加@Value(“${属性名}”): 1 @RestController 2 public class MiyaController { 3 4 @Value("${my.name}") 5 private String name; 6 @Value("${my.age}") 7 private int age; 8 9 @RequestMapping(value = "/miya") 10 public String miya(){ 11 return name+":"+age; 12 } 13 14 }        二、将配置文件的属性赋给实体类    

SpringCloud的自定义参数

送分小仙女□ 提交于 2020-02-15 12:54:05
基于SpringCloud开发框架时,有时候需要添加一些默认参数。 有2种方式可以实现。 PropertySourceLocator接口。 import org . springframework . cloud . bootstrap . config . PropertySourceLocator ; public class MyPropertySourceLocator implements PropertySourceLocator { @Override public PropertySource < ? > locate ( Environment environment ) { Map < String , Object > properties = new HashMap < > ( ) ; properties . put ( "waitTime" , "1h" ) ; properties . put ( "seconds" , "5s" ) ; PropertySource source = new MapPropertySource ( "MyProperty" , properties ) ; return source ; } } 需要有configuration类 @Configuration public class

java 读取配置文件例子

只谈情不闲聊 提交于 2020-02-12 15:15:06
File f = new File(this.getClass().getResource("/").getPath()+"xxx.properties"); try( FileInputStream d=new FileInputStream(f)) { Properties properties=new Properties(); properties.load(d); System.out.println(f.toString()); System.out.println(properties.getProperty("com.outpupath")); } catch (IOException e) { e.printStackTrace(); } 配置文件在resource文件下 内容 com.outpupath=E:/x/xxxx.xlsx 来源: https://www.cnblogs.com/funkboy/p/12299119.html

Visual Studio - Debug vs Release

只愿长相守 提交于 2020-02-12 09:19:17
问题 I built a windows service, targeted for .NET 2.0 in VS 2008. I run it as a console app to debug it. Console app is working great. I put it on my local computer as a service, compiled in debug mode, still working great. I'm ready to release now, and suddenly, when I set it to release mode, the service compiles and installs, but nothing happens. (No code in service is running at all). I realize that the release vs debug mode are property configuration settings, but it seems that in release mode

Visual Studio - Debug vs Release

柔情痞子 提交于 2020-02-12 09:17:44
问题 I built a windows service, targeted for .NET 2.0 in VS 2008. I run it as a console app to debug it. Console app is working great. I put it on my local computer as a service, compiled in debug mode, still working great. I'm ready to release now, and suddenly, when I set it to release mode, the service compiles and installs, but nothing happens. (No code in service is running at all). I realize that the release vs debug mode are property configuration settings, but it seems that in release mode

JAVA的Properties集合

我怕爱的太早我们不能终老 提交于 2020-02-10 19:46:36
Properties import java . io . * ; import java . util . Properties ; import java . util . Set ; /* java.util.Properties集合 extends HashTable<k,v> implements Map<K,V> Properties 类表示了一个持久的属性集 Properties 可保存在流中或从流中加载 Properties 集合是一个为一和IO流相结合的集合 可以使用Properties集合中的方法store,把集合中的临时数据,持久化写入到硬盘中存储 可以使用Properties集合中的方法load,把硬盘中保存的文件(键值对),读取到集合中使用 属性列表中每个键及其对应的值都是一个字符串 Properties集合是一个双列集合,key和value默认都是字符串 */ public class Demo01Properties { public static void main ( String [ ] args ) throws IOException { //show01(); //show02(); show03 ( ) ; } /* 可以使用Properties集合中的方法load,把硬盘中保存的文件(键值对),读取到集合中使用 void load

徒手撸一个 Spring Boot 中的 Starter ,解密自动化配置黑魔法!

蓝咒 提交于 2020-02-10 13:28:45
原文: https://mp.weixin.qq.com/s/tKr_shLQnvcQADr4mvcU3A 我们使用 Spring Boot,基本上都是沉醉在它 Stater 的方便之中。Starter 为我们带来了众多的自动化配置,有了这些自动化配置,我们可以不费吹灰之力就能搭建一个生产级开发环境,有的小伙伴会觉得这个 Starter 好神奇呀!其实 Starter 也都是 Spring + SpringMVC 中的基础知识点实现的,今天松哥就来带大家自己来撸一个 Starter ,慢慢揭开 Starter 的神秘面纱! 核心知识 其实 Starter 的核心就是条件注解 @Conditional ,当 classpath 下存在某一个 Class 时,某个配置才会生效,前面松哥已经带大家学习过不少 Spring Boot 中的知识点,有的也涉及到源码解读,大伙可能也发现了源码解读时总是会出现条件注解,其实这就是 Starter 配置的核心之一,大伙有兴趣可以翻翻历史记录,看看松哥之前写的关于 Spring Boot 的文章,这里我就不再重复介绍了。 定义自己的 Starter 定义 所谓的 Starter ,其实就是一个普通的 Maven 项目,因此我们自定义 Starter ,需要首先创建一个普通的 Maven 项目,创建完成后,添加 Starter 的自动化配置类即可,如下

Android保存用户名和密码

北战南征 提交于 2020-02-09 01:03:18
我们不管在开发一个项目或者使用别人的项目,都有用户登录功能,为了让用户的体验效果更好,我们通常会做一个功能,叫做保存用户,这样做的目地就是为了让用户下一次再使用该程序不会重新输入用户名和密码,这里我使用3种方式来存储用户名和密码 1、通过普通 的txt文本存储 2、通过properties属性文件进行存储 3、通过SharedPreferences工具类存储 第一种: /** * 保存用户名和密码的业务方法 * * @param username * @param password * @return */ public static boolean saveUserInfo(String username, String password) { try { // 使用当前项目的绝对路径 File file = new File("data/data/com.example.android_file_handler/info.txt"); // 创建输出流对象 FileOutputStream fos = new FileOutputStream(file); // 向文件中写入信息 fos.write((username + "##" + password).getBytes()); // 关闭输出流对象 fos.close(); return true; } catch

自定义流程

风流意气都作罢 提交于 2020-02-08 16:51:43
流程包括:事件、活动、流、节点 事件 **Event:流程的状态,无条件执行 属性:id、name 起始 <startEvent id="***" name="***" /> 结束 <endEvent id="***" name="***" /> 活动 activity:单个的任务属性:id、name、URI子元素1:input 属性:name、type、UIR 子元素2:output 属性:name、type、UIR如:决策服务 <activity id="decide1" name="决策服务1" URI="www.baidu.com">   <input name="Strategy1.xls" type="File" UIR="www.google.com/1" />   <input name="Result.properties" type="File" UIR="www.google.com/2" />   <output name="Strategy3.xls" type="File" UIR="www.google.com/3" />   <output name="Result2.properties" type="File" UIR="www.google.com/4" /> </activity> 流 flow:箭头属性:id、name、from、to

How to delete object property?

亡梦爱人 提交于 2020-02-08 09:49:31
问题 According to the docs the delete operator should be able to delete properties from objects. I am trying to delete properties of an object that are "falsey". For example, I assumed the following would remove all of the falsey properties from testObj but it does not: var test = { Normal: "some string", // Not falsey, so should not be deleted False: false, Zero: 0, EmptyString: "", Null : null, Undef: undefined, NAN: NaN // Is NaN considered to be falsey? }; function isFalsey(param) { if (param