我使用Spring的MessageSource
加載來自類路徑中的.properties
文件的錯誤消息。我的屬性遵循一定的「模板」,如{Object}.{field}.{unrespectedConstraint}
例如:Spring引導yml ResourceBundle文件
userRegistrationDto.password.Size= Le mot de passe doit avoir au minimum 6 caractères.
userRegistrationDto.email.ValidEmail= Merci de saisir une addresse mail valide.
在重構的情況下(改變例如對象的名稱),我不得不改變我的屬性在幾個地方文件。
有沒有辦法使用YAML文件(messages.yml)作爲一個資源包來獲得類似:
userRegistrationDto:
password:
Size: Le mot de passe doit avoir au minimum 6 caractères.
email:
ValidEmail: Merci de saisir une addresse mail valide.
那麼,有(免責聲明:自己沒有測試過):https://github.com/akihyro/yaml-resource-bundle – vtosh