激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - Java開發(fā)中常用記錄

Java開發(fā)中常用記錄

2023-05-08 01:07未知服務(wù)器之家 Java教程

一、編程式事務(wù) 1.在執(zhí)行事務(wù)提交或者回滾之前,事務(wù)狀態(tài)不確定時,可以判斷一下事務(wù)是否已完成,避免重復(fù)提交或者回滾出現(xiàn)異常 舉例: TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);if (!tran

一、編程式事務(wù)

1.在執(zhí)行事務(wù)提交或者回滾之前,事務(wù)狀態(tài)不確定時,可以判斷一下事務(wù)是否已完成,避免重復(fù)提交或者回滾出現(xiàn)異常

舉例:

TransactionStatus transactionStatus =  platformTransactionManager.getTransaction(transactionDefinition);
if (!transactionStatus.isCompleted()) {
    platformTransactionManager.commit(transactionStatus);
}

?2.由于編程式事務(wù)不會自動提交或者回滾,我們可以在try-catch之后加一個finally,判斷事務(wù)未完成時,進行回滾,保證每個事務(wù)一定會結(jié)束

舉例:

TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
try {
    ... ...
} catch (Exception ex) {
    ... ...
} finally {
    if (!transactionStatus.isCompleted()) {
        platformTransactionManager.rollback(transactionStatus);
    }
}

二、Stream

1.使用到的數(shù)據(jù)結(jié)構(gòu)及模擬數(shù)據(jù)

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class Student {
    @ApiModelProperty(value = "學(xué)生ID")
    private String studentId;
    @ApiModelProperty(value = "學(xué)生姓名")
    private String studentName;
    @ApiModelProperty(value = "學(xué)生性別,1-男,2-女")
    private String studentSex;
    @ApiModelProperty(value = "學(xué)生年齡Integer")
    private Integer studentAgeInt;
    @ApiModelProperty(value = "學(xué)生年齡Double")
    private Double studentAgeDou;
    @ApiModelProperty(value = "學(xué)生年齡BigDecimal")
    private BigDecimal studentAgeDec;
}
// 數(shù)據(jù)列表 List
List<Student> studentList = new ArrayList<>();
Student student = new Student();
student.setStudentId("20220930000001");
student.setStudentName("趙甲");
student.setStudentSex("1");
student.setStudentAgeInt(11);
student.setStudentAgeDou(11.11);
student.setStudentAgeDec(new BigDecimal(11.11));
studentList.add(student);
student = new Student();
student.setStudentId("20220930000002");
student.setStudentName("錢乙");
student.setStudentSex("2");
student.setStudentAgeInt(12);
student.setStudentAgeDou(12.12);
student.setStudentAgeDec(new BigDecimal(12.12));
studentList.add(student);
student = new Student();
student.setStudentId("20220930000003");
student.setStudentName("孫丙");
student.setStudentSex("1");
student.setStudentAgeInt(13);
student.setStudentAgeDou(13.13);
student.setStudentAgeDec(new BigDecimal(13.13));
studentList.add(student);
student = new Student();
student.setStudentId("20220930000004");
student.setStudentName("李丁");
student.setStudentSex("2");
student.setStudentAgeInt(14);
student.setStudentAgeDou(14.14);
student.setStudentAgeDec(new BigDecimal(14.14));
studentList.add(student);
student = new Student();
student.setStudentId("20220930000005");
student.setStudentName("周戊");
student.setStudentSex("1");
student.setStudentAgeInt(15);
student.setStudentAgeDou(15.15);
student.setStudentAgeDec(new BigDecimal(15.15));
studentList.add(student);
// 數(shù)據(jù)Map
Map<String,Student> studentMap = new HashMap<>(5);
Student student = new Student();
student.setStudentId("20220930000001");
student.setStudentName("趙甲");
student.setStudentSex("1");
student.setStudentAgeInt(11);
student.setStudentAgeDou(11.11);
student.setStudentAgeDec(new BigDecimal(11.11));
studentMap.put(student.getStudentId(),student);
student = new Student();
student.setStudentId("20220930000002");
student.setStudentName("錢乙");
student.setStudentSex("2");
student.setStudentAgeInt(12);
student.setStudentAgeDou(12.12);
student.setStudentAgeDec(new BigDecimal(12.12));
studentMap.put(student.getStudentId(),student);
student = new Student();
student.setStudentId("20220930000003");
student.setStudentName("孫丙");
student.setStudentSex("1");
student.setStudentAgeInt(13);
student.setStudentAgeDou(13.13);
student.setStudentAgeDec(new BigDecimal(13.13));
studentMap.put(student.getStudentId(),student);
student = new Student();
student.setStudentId("20220930000004");
student.setStudentName("李丁");
student.setStudentSex("2");
student.setStudentAgeInt(14);
student.setStudentAgeDou(14.14);
student.setStudentAgeDec(new BigDecimal(14.14));
studentMap.put(student.getStudentId(),student);
student = new Student();
student.setStudentId("20220930000005");
student.setStudentName("周戊");
student.setStudentSex("1");
student.setStudentAgeInt(15);
student.setStudentAgeDou(15.15);
student.setStudentAgeDec(new BigDecimal(15.15));
studentMap.put(student.getStudentId(),student);

?2.過濾-filter

// 過濾所有女生
List<Student> studentListT = studentList.stream()
        .filter(item -> "2".equals(item.getStudentSex())).collect(Collectors.toList());
// 過濾12歲以上學(xué)生(3種數(shù)據(jù)類型示例)
studentListT = studentList.stream().filter(item -> item.getStudentAgeInt() > 12).collect(Collectors.toList());
studentListT = studentList.stream().filter(item -> item.getStudentAgeDou() > 12).collect(Collectors.toList());
studentListT = studentList.stream()
        .filter(item -> item.getStudentAgeDec().compareTo(new BigDecimal(12)) > 0).collect(Collectors.toList());
// 過濾12歲以上男生(2種方法示例)
studentListT = studentList.stream().filter(item -> "1".equals(item.getStudentSex()))
        .filter(item -> item.getStudentAgeInt() > 12).collect(Collectors.toList());
studentListT = studentList.stream()
        .filter(item -> "1".equals(item.getStudentSex()) && item.getStudentAgeInt() > 12).collect(Collectors.toList());

三、Map轉(zhuǎn)對象

最近,研究map與java對象之間的相互轉(zhuǎn)換,總結(jié)了5種方法

https://www.likecs.net/article/190478.htm

四、Linux常用命令

1.查看所有java進程

ps -ef | grep java

2.結(jié)束某個進程

kill -9 pid

原文地址:https://blog.csdn.net/weixin_44200996/article/details/127067774

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 电视剧全部免费观看 | 91精品动漫在线观看 | 亚洲精品一二三区 | 欧美三级欧美成人高清www | 92看片淫黄大片一级 | 最新黄色电影网站 | 国产精品毛片无码 | 久久国产成人精品国产成人亚洲 | 水多视频在线观看 | 亚洲成人免费视频在线 | 日韩精品中文字幕一区二区三区 | 色吧久久| 羞羞视频一区二区 | 91精品国产综合久久婷婷香蕉 | 精品999www| 污视频在线免费播放 | 有兽焉免费动画 | 日本黄色一级毛片 | freexxx69性欧美hd | 黄色毛片免费看 | 精品国产91久久久久久浪潮蜜月 | 欧美a在线 | 亚洲人片在线观看 | 黄色成人短视频 | 久综合| 精品在线免费播放 | 美女扒开胸罩给男生看视频 | 成人福利在线看 | 一区二区免费看 | 久久久久一本一区二区青青蜜月 | 亚洲va久久久噜噜噜久久男同 | 九九热精品视频在线免费观看 | 九九综合视频 | 91精品国产91久久久久久蜜臀 | 成人性生活视频在线播放 | 国产精品久久久久久久久久免 | 性欧美在线视频 | 新久草视频 | 一级外国毛片 | 国产精品一区二区三区在线看 | 成人在线观看免费爱爱 |