with spring boot 3, i have a messages.properties. We use only one langage.
Is there a way to get value from this file when we use log
log.info("user.created");
that will display
user has been created
Related
I want to configure the CosmosQueryRequestOptions.maxDegreeOfParallelism while using the CosmosRepository. I didn't find any documentation around it.
This blog shows how to configure and use this setting through a custom client, but I want to use the repository instead. https://medium.com/#middha.nishant173/improve-query-performance-with-azure-cosmosdb-java-sdk-v4-db1fc54cb484
CosmosQueryRequestOptions is implementation detail for Spring Data Cosmos SDK, so customers cannot set it through spring application.
This can be implemented as a new feature, and can be exposed through application.properties via query.maxDegreeOfParallelism - which customers can opt in if they want.
Default value for maxDegreeOfParallelism is 0, which is the right value for single partition queries. For cross partition queries in the current SDK version, you can get the cosmosClient through spring boot applicationContext and run the query directly against the client. This example shows how to do it - https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/repository/integration/PageableAddressRepositoryIT.java#L144
It seems that Spring is not reading the customized keys for sanitizing the values.(it is only referring to default ones)
I have added below properties in application.properties file
endpoints.env.id=env
endpoints.env.sensitive=true
endpoints.env.enabled=true
endpoints.env.keys-to-sanitize=port
After starting the app and navigating to /env endpoint I am getting below response
"endpoints.env.keys-to-sanitize":{"value":"port","origin":"URL
[file:./application.properties]:40:32"},"endpoints.env.sensitive":{"value":"true","origin":"URL
[file:./application.properties]:41:25"},"endpoints.env.enabled":{"value":"true","origin":"URL
[file:./application.properties]:42:23"},"password":{"value":"******","origin":"URL
[file:./application.properties]:43:10"} ,
"management.port":{"value":"8081","origin":"URL [file:./application.properties]:36:17"}
Notice that port are still visible and the password is masked with ****.
Am I missing something. My requirement is to add few more keys to hide their values.
If you are using Spring Boot version 2 and above, the properties have changed.
You can follow the Actuator Migration Guide for more details.
I am working with a spring boot application, in that application there is a config to set spring active profile:
{Library}/bootstrap.properties
spring.profiles.active=standalone
Let say I want to add on top of the above config, so it becomes
{My App}/bootstrap.properties (What I current can do)
spring.profiles.active=standalone,myprofile
But I don't want to specified standalone, I want to specified the default properties from the library (i.e. default active profiles from the library) so I can make sure my property is future proofed.
So I want something like this:
{My App}/bootstrap.properties (What I want to achieve)
spring.profiles.active={Library spring.profiles.active},myprofile
And {Library spring.profiles.active} in the above will translate to standalone
Any method the achieve the above? Thanks.
I'm using camel in spring boot. I want to save file in dynamic name. Example using current timestamp for file name like "Prefix-20170612115230.xml". I can do that if I hard code it like from(FTP).marshal().to("file:tmp/outbound?fileName=Prefix-${date:now:yyyyMMddHHmmss}.xml").
But if I add this value to application.properties as outbound.ftp.location=file:tmp/outbound?fileName=CA-RP-na-${date:now:yyyyMMddHHmmss}.xml and using this value in route as from(FTP).marshal().to("{{outbound.ftp.location}}"), then the file name is something like Prefix-now:yyyyMMddHHmmss.xml.
What is the right way to use application.properties for this. I guess I need to escape $ sign but escaping it like #{'$'} didn't help.
Use $simple{date:now:yyyyMMddHHmmss}, see the alternative syntax information bot at: http://camel.apache.org/simple.html
How can I insert data to a table on Spring Boot application start? My application is generated by JHipster. What I need to check is that if that particular data already exist in that table or not. If it doesn't I should add it.
If your application was generated by JHipster, then it should already include and be properly configured for Liquibase.
You have a few options:
You can use Liquibase's insert change to insert data.
You can put your data in a CSV file and use the loadData change to load it. Look for the loadData tag in 00000000000000_initial_schema.xml for examples.
You can use the sql change to run native SQL directly.
All three options can be combined with preconditions to make sure the data doesn't exist before trying to insert it. If you need the changeset to run every time you boot your application, you can use the runAlways="true" attribute (docs for that are on this page).
You can create a function in your service class which checks if the data already exists or not and if not then save that data.
You can implement an ApplicationRunner and use a repository to do whatever you need to do.
If the ApplicationRunner is a spring bean it is run on application startup.
For more sophisticated requirements I would try to rely on a tool like flyway that has good integration with spring boot