记录工作中用到的一些工具、方法、问题等。
远程调试
远程调试 启动端口8084,debug监听端口是8085
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8085 -jar /opt/yinsuankeji/digit.jar --server.port=8084 &
JDK17安装
# java 17安装
sudo apt update
sudo apt install openjdk-17-jdk
java -version
开机启动JAVA服务
# 新建website.ervice
sudo nano /etc/systemd/system/website.ervice
# 加入以下内容
[Unit]
Description=website server
[Service]
User=root
ExecStart=/usr/bin/java -jar -Xmx400m /opt/yinsuankeji/website/website_v1.1.0.jar --server.port=8082
SuccessExitStatus=143
TimeoutStopSec=10
Restart=no-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
# 重新加载systemd的配置文件,以使其生效
sudo systemctl daemon-reload
# 重新启动指定的服务
sudo systemctl restart website.service
# 验证服务
systemctl status website.service
方法-交集-并集去重
/**
* 交集
*
* @param lists 双重列表A
* @param lists2 双重列表B
* @return 返回交集
*/
private static List<List<Long>> getLists(List<List<Long>> lists, List<List<Long>> lists2) {
List<List<Long>> newLists = new ArrayList<>();
for (int i = 0; i < lists.size(); i++) {
List<Long> longs = lists.get(i);
List<Long> longs2 = lists2.get(i);
List<Long> insertList = longs.stream().filter(longs2::contains).collect(Collectors.toList());
newLists.add(insertList);
}
return newLists;
}
/**
* 集并去重
*
* @param lists 双重列表A
* @param lists2 双重列表B
* @return 返回并集并去重
*/
private static List<List<Long>> getListsDistinct(List<List<Long>> lists, List<List<Long>> lists2) {
// 拼接
List<List<Long>> newLists = new ArrayList<>();
for (int i = 0; i < lists.size(); i++) {
List<Long> longs2 = lists2.get(i);
List<Long> longs = lists.get(i);
List<Long> mergedList = Stream.concat(longs.stream(), longs2.stream()).distinct().collect(Collectors.toList());
newLists.add(mergedList);
}
return newLists;
}