- 博客(10)
- 收藏
- 关注
原创 通过Environment中取key含有自定义的值,放入JSONObject中
前端时间,要用Environment中获取内容,但是网上基本上找不到。需求:在application.yml中,myshelf.test后含有自定义的内容,在Springboot启动时,无法对application.yml中的XXX进行绑定赋值到实体类的属性上。-application.ymlmyshelf: test: xxxx开始@Autowiredprivate Environment env;public JSONObject getEnvTest(){JSONObject
2021-06-26 13:01:24
271
原创 maven打可执行jar包
<build> <finalName>myshlf-test</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration><skipT
2021-06-01 14:48:57
123
原创 读取jar中MF文件以及pom.xml中的版本号
前端时间,接到了,让读取项目的版本号,如果仅仅是开发环境的话,可以直接读取pom文件,但是如果是jar或者是war时,可能就不到jar里面的pom.xml,所以最后查看jar中有MANIFEST.MF有版本号,同时采用这个方法。因为项目关系就不进行截图了。第一种:读取pom.xml的版本号(仅仅适合开发环境使用):引入依赖<dependency> <groupId>org.apache.maven</groupId> <artifactId>mave
2020-11-04 11:18:24
1751
3
原创 junit4 测试代码覆盖率,被测试方法含有全局变量(SpringBoot等适用)
如果用junit4 测试代码覆盖率,而方法中使用了全局变量,针对这个问题,今天留下保存,以便后期使用。//TestApublic class TestA{ @Autowired private TestB testB; String[] str = {"-","="}; public void getTestB(){ testB = new TestB(); String text = testB.getName()+str[0]+testB.getAge(); System.out.pr
2020-09-11 15:52:35
1262
原创 通过栈(先进后出)思想把{}{}之间的数据放到集合中
public void static main(String[] args){String text ="{a:A,b:B}|{c:C,d:D};{e:E,f:F} {h:H,q:Q}";List<String> List = new ArrayList<String>();StringBuffer sb = new StringBuffer("");//申明一个stackStack<Character> stack = new Stack<Charact
2020-09-11 15:28:17
133
转载 用StringBuffer和正则表达式 替换小括号()中的双引号
String str = "{\"a\":\"A\",\"b\":\"@java.lang.Integer@parseInt(str.substring(1\",\"string.length()-1))\"}"; //匹配小括号的内容 Pattern p = Pattern.compile("\\((.*)\\)"); Matcher m = p.matcher(str); String temp = null; StringBuffer sb = new Strin
2020-09-11 14:50:09
712
原创 nginx替换配置文件nginx.conf并启动nginx 脚本
#!/bin/sh#脚本的当前位置url=`dirname $0`cd $url#获取进入的目录位置pass=`pwd`nginxConfPath="/nginx.conf"#把nginx.conf文件放置到目录下appNginxConfPath="/app/temp"deployDirPath="/home/dede"deployNginxConfPath="/nginx/conf"nPass="/nginx/"cd $deployDirPathconf=`pwd`#把/app
2020-07-16 09:51:57
1077
原创 win10 win7 截图快捷键
1.win10截图快捷键 win+shift+A2.win7截图快捷键 选中截图工具,右键,在快捷键同时按 Ctrl+Shift+A ==> Ctrl+Shift+A3.新建txt文件,输入: start snippingtool 保存成 截图.bat ;双击也可以截图...
2020-06-05 13:35:16
458
原创 List去重
List去重1、List去重list.stream().distinct().collect(Collectors.toList());2、List 去重List lst = getFunction()(获取数据库的数据);//去重含有实体类的List集合,并保持顺序不变Set newSet = new HashSet();List nList = new ArrayList();...
2020-05-02 15:45:47
264
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人