Change hibernate ValidationMessage.properties - spring

i want to change default spring validation message file from ValidationMessage_en.properties to ValidationMessage_fa.properties file
the ValidationMessage_fa.properties still exist in org/hibernate/validator/ValidationMessages_fa.properties or in detail (.m2/repository/org/hibernate/validator/hibernate-validator/6.2.5.Final/hibernate-validator-6.2.5.Final-sources.jar!/org/hibernate/validator/ValidationMessages_fa.properties)
but i dont how to replace that

add config item as follow:
spring.web.locale=fa
spring.web.locale-resolver=fixed

Related

In Spring boot, I'm trying to create another .property file that functions like messages.property, Is that possible?

So I'm trying to create another .property file (called labels.properties) that i can use in Thymeleaf like this:
<div th:text=#{property.from.labels}></div>
Right now I just add labels.properties in the root of resource folder, for now its not working. The purpose of this is I want to separate the property file that handles the error messages from texts for labels & buttons.
Is that possible?
if yes, how to do it?
if yes again, can I do internationalization like adding labels_ja.properties (Japanese)?
You can customize the naming (and location) of the message bundles by configuring the spring.messages.basename property. For example:
spring.messages.basename=labels
By doing so, Spring will look for messages within classpath:labels.properties and classpath:labels_{locale}.properties, such as classpath:labels_ja.properties.
If you want to use this in addition to the regular messages.properties, you can use a comma separated value:
spring.messages.basename=messages,labels
The first one within that comma separated list will take priority over the other ones. If you have a property.from.labels in both messages.properties and labels.properties, the one within messages.properties would be chosen in this example.
This can also be found within the documentation about internationalization.

spring cloud stream multi sink with dynamic destinations

I need to use dynamic group names for RabbitMQ binder based Multisink (multiple sinks) app.
Seems like the
spring.cloud.stream.bindings..group property can't be set at runtime.
Any thoughts on how to go about it ?
SPB: 2.2.8.RELEASE ,
spring-cloud-dependencies: Hoxton.SR6 ,
spring-cloud-stream-dependencies: Horsham.SR6
Thanx,
You can use a property placeholder there...
spring.cloud.stream.bindings.input-in-0.group=${group.prop:foo}
...and then set the property on the command line:
-Dgroup.prop=bar

What NOREPLACE means at netflix's nebula plugin?

I was using netflix's nebula. Looking here, I saw this line:
fileType [org.freecompany.redline.payload.Directive] - Default for types, e.g. CONFIG, DOC, NOREPLACE, LICENSE
I didn't find any doc about the actual meaning of this enum, but I've found the original code.
Now I want an actual description of this enum. I thought NOREPLACE is releated to being not allowed to replace the file. But I want to be sure and don't rely on assumptions.
I have only seen noreplace as an additional attribute on a config file, e.g. %config(noreplace). It means that if the user has edited the file, the installer should put its new version as filename.rpmnew; by default %config files are replaced with the user one put as filename.rpmold .

Spring boot: Override property value

Into my application-pre.properties file there's coded this property:
scheduler.url-backoffice=http://${BACKOFFICE_SERVICE}:8080
In order to fill it, I'm using -Dspring-boot.run.arguments=--spring.config.additional-location=scheduler-config.properties.
scheduler-config.properties:
BACKOFFICE_SERVICE=localhost
scheduler.url-backoffice=http://localhost:8081
I need to set BACKOFFICE_SERVICE property, otherwise spring doesn't start. So, it means that scheduler.url-backoffice comes to http://localhost:8080.
I 've added another line after that in order override its value.
My surprise is its value is not changed. I mean, scheduler.url-backoffice's value is http://localhost:8080 instead of http://localhost:8081.
I'm not able to change application-pre.properties content file.
Use multiple application properties files.
One can ship in the jar;
this contains the defaults.
For me, defaults translates to either the prod values,
if there is only one set of prod values,
or the developer local values (which should cause failures in production).
The second file contains the environment specific property values that
override the defaults.
You must change your startup values to achieve this.
Here is an example:
-Dspring-boot.run.arguments=--spring.config.additional-location=scheduler-config.properties,local-scheduler-config.properties
Edit: in response to "still not working".
It seems like you need much more than the "simple" approach I described above.
For that,
check out section 24. Externalized Configuration in the Spring Boot Reference Guide.
There are many techniques to override configuration values;
all are covered in the reference guide.

Maven properties plugin. Set default value if property isn't found

Is it possible with properties-maven-plugin to set default value for some property name if it is not found in property file or property file doesn't exists?
EDIT: one possible workaround is to use another profile named for example "set-default-properties" and call it when default settings need. But actually this is not exactly what I want.

Resources