Spring Boot Runtime Property Changes After Deploying Start of Application - spring-boot

I came across a requirement of switch on/off case in Spring Boot Application. We have a notification service implemented which is working on property :
notifyall = true in application.properties file.
Now I want to stop the notification services by specifying notifyall = false in application.properties file without any downtime.
Is it possible in Spring Boot Application?
If yes, then any step wise approach or relevant tutorial will be of great help.
Thanks

Use spring boot actuators.
Please go through the following link: https://projects.spring.io/spring-cloud/spring-cloud.html#_environment_changes
it mentions #ConfigurationProperties with prefix; any change in the configuration will be loaded automatically.

Related

what does "spring-kafka without springboot" mean

I'm totally new to Kafka and terribly confused by this:
https://docs.spring.io/spring-kafka/reference/html/#with-java-configuration-no-spring-boot
I don't understand what that even means. What does "no spring boot mean" because that example sure as hell uses spring boot. I'm so confused....
EDIT
if I'm using SpringBoot and spring-kafka, should I have to manually create #Bean ConcurrentKafkaListenerContainerFactory as shown here. Most of the examples in the docs for setting up filtering / config / etc seem to use the "manual" configuration using #Bean. Is that "normal"? The docs are very confusing to me...especially this warning:
Spring for Apache Kafka is designed to be used in a Spring Application Context. For example, if you create the listener container yourself outside of a Spring context, not all functions will work unless you satisfy all of the …​Aware interfaces that the container implements.
It's referring to the autowired configuration, as compared to putting each property in the config via HashMap/Properties in-code.
Also, it does not use #SpringBootApplication or SpringApplication.run, it just calls a regular main method using a hard-coded Config class.
Spring boot contains the functionality of AutoConfiguration
What this means is that spring boot when discovers some specific jar dependencies it knows, in the project, it automatically configures them to work on a basic level. This does not exist in simple Spring project where even if you add the dependency you have to also provide the configuration as to how it should work in your application.
This is also happening here with dependencies of Kafka. Therefore the documentation explains what more you have to configure if you don't have spring-boot with auto-configuration to make kafka work in a spring project.
Another question asked in comment is what happens in case you want some complex custom configuration instead of the automatic configuration provided while you are in a spring-boot app.
As documented
Auto-configuration tries to be as intelligent as possible and will
back-away as you define more of your own configuration. You can always
manually exclude() any configuration that you never want to apply (use
excludeName() if you don't have access to them). You can also exclude
them via the spring.autoconfigure.exclude property.
So if you want to have some complex configuration which is not automatically provided by spring-boot through some other mechanism like a spring-boot specific application property, then you can make your own configuration with your custom bean and then either automatic configuration from spring-boot for that class will back of as spring does several intelligent checks during application context set up or you will have to exclude the class from auto configuration manually.
In that case you could probably take as an example reference of how to register manually your complex configurations in spring boot what is documented on how to be done in non spring boot app. doc

Passing configuration from yaml file to spring boot application without rebuilding it

How to pass configuration through yaml file to a running spring boot application so that there is no need of rebuilding the application and changes are reflected while the application is runnig?
I think this can help you:
How to hot-reload properties in Java EE and Spring Boot?
Take a look at Spring Boot Cloud Config. It allows you to manage your config files centralized and has the ability to push new configurations to the connected applications.

Is there a way to disable ReactiveHealthIndicators in Spring Boot 2 Actuator?

Using Spring Boot 2.1.2 Actuator. I have Redis in my classpath. Actuator is automatically enabling RedisReactiveHealthIndicator. I don't want that. My app is not reactive. I want RedisHealthIndicator, but the reactive one is replacing it.
Is there a way to stop auto-enabling of reactive health indicators?
management.health.redis.enabled = false
Add this to your application.properties file.
Hope this helps ;)
Than try this
#EnableAutoConfiguration(exclude={RedisReactiveHealthIndicator.class})

Is that possible to use ObjectDB in a Spring Boot application

I want to use ObjectDB in my Spring Boot application. How should I configure the application.yml file?
I don't want to add persistence.xml into my application. Is that possible?
You can follow this tutorial:
http://spring.io/guides/gs/accessing-data-jpa/
with adjustments to ObjectDB, as explained on this forum thread:
http://www.objectdb.com/database/forum/860

Spring Security-Reload my security.xml on edit

I am using Spring Security in my project. I have a situation where I need to change the pattern attribute in itercept-url tag on runtime. For this I have to again restart the tomcat server and in turn takes a lot of time for me to test my changes.
Does Spring have a solution where the security.xml file is reloaded when I edit it in my web application, without restarting my server. Please provide some pointers for the same as I am new to Spring Framework.
Any link to a step by step tutorial will certainly help a lot.
Thanks in advance.
Divyang Agrawal
Use spring annotation rather than using xml configuration. so by using annotation you do not required tomcat restart after changing the source code.
you can find simple tutorial for how to use annotation based spring security here Link

Resources