I want to use #ConfigurationProperties and bind some properties in application.properties to that class. When I exclude embedded tomcat dependency from pom.xml, I cant use those properties defined in #ConfigurationProperties class. How can I solve the problem when using an external tomcat?
Related
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.
I want to load a bean from a external jar into spring boot project. But I don't want to make changes to existing spring boot config file. I want same behavior like actuator. Just add dependency and bean or endpoint will be available in spring boot
I have a Spring Boot web app A and its dependent on a Spring Boot jar library B. I have some properties that I want to configure within B and don't want the client apps (e.g. the web app A) to configure them. I have these properties files in B.
application-dev.properties
application-stage.properties
applicatino-live.properties
The issue is that these properties are not recognized when the library is added as a dependency in web app A. What is the way to achieve this?
The PropertySource annotation can be used in a Configuration class on webapp A to achieve what you're looking for:
#Configuration
#PropertySource("classpath:application-dev.properties"),
#PropertySource("classpath:application-stage.properties"),
#PropertySource("classpath:application-live.properties")
public class WebappAConfiguration {
}
I also found the order that spring boot looks for externalized configuration helpful here.
i have two projects one for cache and other to use it. I have added the dependency of cache project as jar in my spring-boot application. but the classes mentioned with #Resouce i am not able to access in my spring boot application. how to resolve it?
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.