-Xms设置堆的最小空间大小。
-Xmx设置堆的最大空间大小。
-XX:NewSize设置新生代最小空间大小。
-XX:MaxNewSize设置新生代最大空间大小。
-XX:PermSize设置永久代最小空间大小。
-XX:MaxPermSize设置永久代最大空间大小。
-Xss设置每个线程的堆栈大小。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
行为参数(功能开关) -XX:-DisableExplicitGC 禁止调用System.gc();但jvm的gc仍然有效 -XX:+MaxFDLimit 最大化文件描述符的数量限制 -XX:+ScavengeBeforeFullGC 新生代GC优先于Full GC执行 -XX:+UseGCOverheadLimit 在抛出OOM之前限制jvm耗费在GC上的时间比例 -XX:-UseConcMarkSweepGC 对老年代采用并发标记交换算法进行GC -XX:-UseParallelGC 启用并行GC -XX:-UseParallelOldGC 对Full GC启用并行,当-XX:-UseParallelGC启用时该项自动启用 -XX:-UseSerialGC 启用串行GC -XX:+UseThreadPriorities 启用本地线程优先级 性能调优 -XX:LargePageSizeInBytes=4m 设置用于Java堆的大页面尺寸 -XX:MaxHeapFreeRatio=70 GC后java堆中空闲量占的最大比例 -XX:MaxNewSize=size 新生成对象能占用内存的最大值 -XX:MaxPermSize=64m 老年代对象能占用内存的最大值 -XX:MinHeapFreeRatio=40 GC后java堆中空闲量占的最小比例 -XX:NewRatio=2 新生代内存容量与老生代内存容量的比例 -XX:NewSize=size 新生代对象生成时占用内存的默认值 -XX:ReservedCodeCacheSize=32m 保留代码占用的内存容量 -XX:ThreadStackSize=512 设置线程栈大小,若为0则使用系统默认值 -XX:+UseLargePages 使用大页面内存 调试参数 -XX:-CITime 打印消耗在JIT编译的时间 -XX:ErrorFile=./hs_err_pid<pid>.log 保存错误日志或者数据到文件中 -XX:-ExtendedDTraceProbes 开启solaris特有的dtrace探针 -XX:HeapDumpPath=./java_pid<pid>.hprof 指定导出堆信息时的路径或文件名 -XX:-HeapDumpOnOutOfMemoryError 当首次遭遇OOM时导出此时堆中相关信息 -XX:OnError="<cmd args>;<cmd args>" 出现致命ERROR之后运行自定义命令 -XX:OnOutOfMemoryError="<cmd args>;<cmd args>" 当首次遭遇OOM时执行自定义命令 -XX:-PrintClassHistogram 遇到Ctrl-Break后打印类实例的柱状信息,与jmap -histo功能相同 -XX:-PrintConcurrentLocks 遇到Ctrl-Break后打印并发锁的相关信息,与jstack -l功能相同 -XX:-PrintCommandLineFlags 打印在命令行中出现过的标记 -XX:-PrintCompilation 当一个方法被编译时打印相关信息 -XX:-PrintGC 每次GC时打印相关信息 -XX:-PrintGCDetails 每次GC时打印详细信息 -XX:-PrintGCTimeStamps 打印每次GC的时间戳 -XX:-TraceClassLoading 跟踪类的加载信息 -XX:-TraceClassLoadingPreorder 跟踪被引用到的所有类的加载信息 -XX:-TraceClassResolution 跟踪常量池 -XX:-TraceClassUnloading 跟踪类的卸载信息 -XX:-TraceLoaderConstraints 跟踪类加载器约束的相关信息 |
View Details
openfire是一个聊天服务端,好比qq服务端.本质是个socker server.
openfire通讯协议是 xmpp ,什么是xmpp参考百科 https://baike.baidu.com/item/XMPP/3430617?fr=aladdin
View Details关于MQTT
MQTT是一个基于客户端-服务器的消息发布/订阅传输协议。MQTT协议是轻量、简单、开放和易于实现的,这些特点使它适用范围非常广泛。在很多情况下,包括受限的环境中,如:机器与机器(M2M)通信和物联网(IoT)。
本文涉及到一些 Java8 的特性。 int[]数组
1 |
int[] data = {4, 5, 3, 6, 2, 5, 1}; |
int[] 转 List<Integer>
1 |
List<Integer> list1 = Arrays.stream(data).boxed().collect(Collectors.toList()); |
Arrays.stream(arr) 可以替换成IntStream.of(arr)。 1.使用Arrays.stream将int[]转换成IntStream。 2.使用IntStream中的boxed()装箱。将IntStream转换成Stream<Integer>。 3.使用Stream的collect(),将Stream<T>转换成List<T>,因此正是List<Integer>。 int[] 转 Integer[]
1 |
Integer[] integers1 = Arrays.stream(data).boxed().toArray(Integer[]::new); |
前两步同上,此时是Stream<Integer>。 然后使用Stream的toArray,传入IntFunction<A[]> generator。 这样就可以返回Integer数组。 不然默认是Object[]。 List<Integer> 转 Integer[]
1 |
Integer[] integers2 = list1.toArray(new Integer[0]); |
调用toArray。传入参数T[] a。这种用法是目前推荐的。 List<String>转String[]也同理。 List<Integer> 转 int[]
1 |
int[] arr1 = list1.stream().mapToInt(Integer::valueOf).toArray(); |
想要转换成int[]类型,就得先转成IntStream。 这里就通过mapToInt()把Stream<Integer>调用Integer::valueOf来转成IntStream。 而IntStream中默认toArray()转成int[]。 Integer[] 转 int[]
1 |
int[] arr2 = Arrays.stream(integers1).mapToInt(Integer::valueOf).toArray(); |
思路同上。先将Integer[]转成Stream<Integer>,再转成IntStream。 Integer[] 转 List<Integer>
1 |
List<Integer> list2 = Arrays.asList(integers1); |
最简单的方式。String[]转List<String>也同理。 String 同理
1 2 3 4 5 6 |
// 同理 String[] strings1 = {"a", "b", "c"}; // String[] 转 List<String> List<String> list3 = Arrays.asList(strings1); // List<String> 转 String[] String[] strings2 = list3.toArray(new String[0]); |
完整代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { int[] data = {4, 5, 3, 6, 2, 5, 1}; // int[] 转 List<Integer> List<Integer> list1 = Arrays.stream(data).boxed().collect(Collectors.toList()); // Arrays.stream(arr) 可以替换成IntStream.of(arr)。 // 1.使用Arrays.stream将int[]转换成IntStream。 // 2.使用IntStream中的boxed()装箱。将IntStream转换成Stream<Integer>。 // 3.使用Stream的collect(),将Stream<T>转换成List<T>,因此正是List<Integer>。 // int[] 转 Integer[] Integer[] integers1 = Arrays.stream(data).boxed().toArray(Integer[]::new); // 前两步同上,此时是Stream<Integer>。 // 然后使用Stream的toArray,传入IntFunction<A[]> generator。 // 这样就可以返回Integer数组。 // 不然默认是Object[]。 // List<Integer> 转 Integer[] Integer[] integers2 = list1.toArray(new Integer[0]); // 调用toArray。传入参数T[] a。这种用法是目前推荐的。 // List<String>转String[]也同理。 // List<Integer> 转 int[] int[] arr1 = list1.stream().mapToInt(Integer::valueOf).toArray(); // 想要转换成int[]类型,就得先转成IntStream。 // 这里就通过mapToInt()把Stream<Integer>调用Integer::valueOf来转成IntStream // 而IntStream中默认toArray()转成int[]。 // Integer[] 转 int[] int[] arr2 = Arrays.stream(integers1).mapToInt(Integer::valueOf).toArray(); // 思路同上。先将Integer[]转成Stream<Integer>,再转成IntStream。 // Integer[] 转 List<Integer> List<Integer> list2 = Arrays.asList(integers1); // 最简单的方式。String[]转List<String>也同理。 // 同理 String[] strings1 = {"a", "b", "c"}; // String[] 转 List<String> List<String> list3 = Arrays.asList(strings1); // List<String> 转 String[] String[] strings2 = list3.toArray(new String[0]); } } |
from:https://zhuanlan.zhihu.com/p/196698839
View DetailsWebRTC能让web应用和站点之间选择性地分享音视频流。在不安装其它应用和插件的情况下,完成点对点通信。 WebRTC背后的技术被实现为一个开放的Web标准,并在所有主要浏览器中均以常规JavaScript API的形式提供。对于客户端(例如Android和iOS),可以使用提供相同功能的库。 WebRTC是个开源项目,得到Google,Apple,Microsoft和Mozilla等等公司的支持。2011年6月1日开源并在Google、Mozilla、Opera支持下被纳入万维网联盟的W3C推荐标准。
View Details单元测试是指对软件中的最小可测试单元进行检查和验证。在Java中,单元测试的最小单元是类。通过编写针对类或方法的小段代码,来检验被测代码是否符合预期结果或行为。执行单元测试可以帮助开发者验证代码是否正确实现了功能需求,以及是否能够适应应用环境或需求变化。
View DetailsMaven项目打包时,如果遇到需要添加本地jar包依赖的时候,可以选择两种方法: 1. 安装到本地仓库 第一种方法比较常规,适用于需要添加的jar包也是由maven项目导出,含有pom文件的时候。只需要将jar包安装到本地maven仓库下,然后添加依赖即可。 (1)安装到本地仓库,执行以下命令(其中的-Dfile/-DgroupId/-DartifactId/-Dversion项根据pom文件内容填写):
1 |
mvn install:install-file -Dfile=xxxxx.jar -DgroupId=xxx.xxx.xxx -DartifactId=xxxxx -Dversion=1.0.0 -Dpackaging=jar |
(2)安装之后可以在本地仓库中找到对应的jar包。然后将对应的依赖信息插入到工程的pom文件即可:
1 2 3 4 5 |
<dependency> <groupId>xxx.xxx.xxx</groupId> <artifactId>xxxxx</artifactId> <version>1.0.0</version> </dependency> |
2. dependency中指定scope="system"和本地jar包路径 这种方法适用于其他方式导出的jar包,jar包中不含有pom信息,从而无法安装进本地仓库的情况。做法是:先配置本地jar包依赖,然后在build时将设置将jar包导出,同时配置manifest。 (1)配置本地jar包依赖(systemPath指向本地jar包路径):
1 2 3 4 5 6 7 |
<dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-s3</artifactId> <version>1.11.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/xxx.jar</systemPath> </dependency> |
(2)在<build>的spring-boot-maven-plugin中设置将本地jar包导出到项目最终的依赖库中:
1 2 3 4 5 6 7 |
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> |
(3)如果项目使用maven-jar-plugin插件打包的话,还需要在manifectEntries中添加对应的jar包信息;否则虽然jar包导出了,但是项目生成的MANIFEST.MF文件中没有对应的依赖信息,也会导致运行时找不到对应的class。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>XXXX</mainClass> </manifest> <manifestEntries> <Class-Path>./ lib/xxxxx.jar</Class-Path> </manifestEntries> </archive> <outputDirectory> ${project.build.directory}/XXXXX </outputDirectory> </configuration> </plugin> |
(4)最后附上一个项目完整的<build>配置(该配置可以将最终生成的jar包和依赖库、配置文件分开)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
<build> <finalName>XXXXX</finalName> <sourceDirectory>src/main/java</sourceDirectory> <resources> <resource> <directory>src/main/resources</directory> <targetPath>${project.build.directory}/XXXXX</targetPath> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> <testSourceDirectory>src/test/java</testSourceDirectory> <testResources> <testResource> <directory>src/test/resources</directory> <filtering>true</filtering> <excludes> <exclude>**/*.java</exclude> </excludes> </testResource> </testResources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory> ${project.build.directory}XXXXX/lib </outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>xxx.xxx.XXXXX</mainClass> </manifest> <manifestEntries> <Class-Path>./ lib/xxxxx.jar</Class-Path> </manifestEntries> </archive> <outputDirectory> ${project.build.directory}/XXXXX </outputDirectory> </configuration> </plugin> </plugins> </build> |
from:https://www.cnblogs.com/strugglion/p/12513956.html
View Detailslt:less than 小于 le:less than or equal to 小于等于 eq:equal to 等于 ne:not equal to 不等于 ge:greater than or equal to 大于等于 gt:greater than 大于 from:https://blog.csdn.net/Radiation_ONE/article/details/108425074
View Details public void groupingByCity() {
Map
map.forEach((k, v) -> {
System.out.println(k + " = " + v);
});
}