AdSense

2021/4/27

Java 字串為null返回空字串,否則返回原字串 String null return empty string else return original string

Java 取得字串時,若希望當該字串為null時返回空字串,不是null返回原本的字串的作法如下。

Java JAXB 物件寫出為xml檔範例 write object to xml file example

Java使用JAXB(Java Architecture for XML Binding)將Java物件寫出為xml檔內的範例如下。

2021/4/26

Golang 我的第一支Go程式 hello world

本篇撰寫Go hello world程式。

Golang 2021 Windows 7 安裝Go lang install golang

本篇記錄在Windows 7安裝Go程式語言。

Spring Boot 使用@Lookup取得prototype bean

Spring IoC管理的bean預設scope為singleton。若bean為有狀態(stateful)時應設為prototype才能使每一次產生的bean實例不同。而當singleton bean要取得依賴的prototype bean的實例時,可使用@Lookup annotation來取得不同的prototype bean的實例。

2021/4/23

JUnit 測試方法中多個Assertions與assertAll()差別 multi-assertions-assertall-difference

JUnit單元測試有時在一個@Test測試方法中會需要用多個Assertions來驗證,例如回傳結果物件的所有屬性是否皆正確。而直接執行多個Assertions及使用JUnit 5才有的Assertions.assertAll()區別如下。

AdSense