アプリのメッセージを保持するために ValidationMessages.properties を使用したくありません。他のすべてが使用するものを使用したい: LabelNames.properties.
それができる方法はありますか?
アプリのメッセージを保持するために ValidationMessages.properties を使用したくありません。他のすべてが使用するものを使用したい: LabelNames.properties.
それができる方法はありますか?
可能です。ResourceBundleMessageInterpolator
とその bundle locator APIを使用できます。カスタム バンドル名は次のように指定できます。
Validator validator =
Validation.byProvider(HibernateValidator.class)
.configure()
.messageInterpolator(
new ResourceBundleMessageInterpolator(
new PlatformResourceBundleLocator( "LabelNames" )))
.buildValidatorFactory()
.getValidator();