spring boot application.yml properties change at runtime - spring

In a spring boot application, I am able to bind properties from application.yml to the bean fields using #ConfigurationProperties annotation.
Is it possible to update these properties in application.yml at runtime and get them reflected in the bean? If yes. How to do this?
In the past, I've gotten this working using ReloadableResourceBundleMessageSource

Spring Cloud Config does that and more. In particular, check the sample application.

Related

How to create a spring boot starter to initialize applications.properties

How can I create a Spring Boot starter to initialize properties automatically instead of adding them on the application.properties of the application?
For example, the configuration below would be done in the starter, not in the application:
server.port=8443
server.ssl.enabled=true
The common usage of starters is to create beans based on some condition. I just need the starter to define default properties and spring would create the beans.
The idea is to have a common set of properties to be used by many projects, just adding the starter as a dependency.

Spring Integration XML Configuration and Spring Boot Java Annotation Configuration

Is it possible to have spring integration xml configuration and spring boot java annotation configuration at the same time? Can you please refer with an example on this?
What is the best practice for this?
Thanks
As Marten pointed out it is fully fine to combine Spring Boot with an XML configuration. See Spring Boot docs: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using.configuration-classes.importing-xml-configuration
If you absolutely must use XML based configuration, we recommend that you still start with a #Configuration class. You can then use an #ImportResource annotation to load XML configuration files.
And here is the sample: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/test/java/smoketest/xml/SampleSpringXmlPlaceholderBeanDefinitionTests.java

How to migrate Spring Boot project to legacy Spring MVC project. Facing problem, how to read application.properties file in legacy Spring MVC project

I have done the POC in Spring Boot application. But our project is running on legacy Spring MVC.
The problem I am facing while converting Spring Boot project to Spring MVC, to read application.properties file.
The content of the Spring Boot application.properties file is as below
okta.oauth2.issuer=https://dev-3038103.okta.com/oauth2/bus3zhc6ayn7hfzQN5d6
resourceServer.url=http://localhost:8082
okta.oauth2.clientId={client-id}
okta.oauth2.clientSecret={secret-id}
okta.oauth2.scopes=openid,profile
server.port=8080
Can anyone please tell me how to handle?
There are many ways to achieve this,
Using PropertyPlaceholderConfigurer
Using PropertySource
Using ResourceBundleMessageSource
Using PropertiesFactoryBean
this is like a go to source.
Register PropertyPlaceholderConfigurer bean-
<context:property-placeholder location="classpath:path/filename.properties"/>
i am providing the implementation with first method however you can very easily about the rest, follow any one

setting liquibase.changelogSchemaName property in spring boot

I am facing issue while setting the changelogSchemaName for liquibase in spring boot.
I am setting it like below -
spring.datasource.datsourcename.liquibase.changelogSchemaName =
But it seems spring boot is not reading this property.
How can this property be set. My problem is I want to use separate schema for changelog tables which i s different from actual schema.
You can use
spring.liquibase.liquibase-schema=
in your application.properties file for the springboot app.

How to set threshold of SlowQueryReport interceptor of Tomcat in Spring Boot properties

We need to configure SlowQueryReport Tomcat interceptor in our Spring boot application, specifically threshold value in properties files. Couldn't find anything on the web. Any help?
We used the old syntax (see below, note the given threshold) in the configuration file and it worked:
spring.datasource:
tomcat.jdbc-interceptors: org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport(threshold=10);any.other.tomcat.Interceptor

Resources