Spring Boot add properties on top of current default properties - spring

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.

Related

Spring properties inside library

So I've got a library which contains default things like authentication and stuff like that, which are all equal across multiple applications.
I'd like to have an application.properties inside the library setting up some default values. But at the same time I would like the actual application to be able to overwrite these library values inside the applications' properties file.
But I can't seem to figure out how to get spring to read the librarys' property file.

Spring Boot #Value Properties Report

I have an Spring Boot application, which has a number of properties and is delivered to an "external" customer.
Most properties have sane defaults, so they are added to application.properties and one can identify them there.
But there are also some properties which do not have a sane default, they must be defined by the external customer, thus they are currently included in application.properties with a dummy-value (to-be-replaced), but it's easy to miss such a property and Spring will not complain the property missing but trying to load it, which sometimes (hostnames, ...) leads to unexpected results.
The project is built with Maven -- is there maybe a way already a way to scan the project during build for all #Value() annotations and generate some kind of report?
Then the devs could define those values-without-default simply using #Value, the report will show them as having no default and one thus knows which properties are necessary to set.

Is there a way to generate application properties when creating a Spring Boot project?

I'm planning to run our own Spring Initializr instance. Is there a way to have a set of application properties get written (to application.yml) when a certain option is chosen, ideally in a separate section for each of a set of predefined profiles? I've looked into customising the project-generation process in Initializr and at creating a custom starter. I've come across auto-configuration for starters, but that seems to be about what configuration to default to when this has not been provided by properties, whereas I am after generating the properties. I've also come across an example of a custom Spring Initializr instance generating files, but I need it to modify application.yml without clobbering any other modifications that may have been made to it.
Spring Initializr (the library behind start.spring.io) does not have yaml support and does not allow you to write such file automatically when the project is generated.
It's easy enough for you to add that feature though. The way it works is through a model that contributors would tune + a writer that transform the model into the target output. An analogy of this would be MavenBuild and MavenBuildWriter that generates Maven's pom.xml.
Auto-configuration is indeed completely unrelated to code/configuration generation so no need to look there.

spring boot: create multiple context for the same application-context.xml

I need to create multiple context for the same application context.xml file and each context use its own application.properties.
How to do it using spring boot ?
I have 3 clients who have the same behaviour but each one with specific details declared into client-application.properties.
So i use also spring integration and the flow will be reused for each client .
I need to launch 3 clients in the same time and each one with its own application.properties. And i use xml for that.
Take a look at this... I have a single project, and inside of it are three application.properties (or the number you need)
in application.properties, i specify general parameters
and in each application-.properties i specify specific environment properties, e.g., the port in production:
And the port for my dev profile:
In order to use them check the documentation that Ivaylo recommended
...A small example:
In this case, the application will boot on the port showed in the different .properties files.
You can specify the profile like: mvn spring:boot run -Dspring.profiles.active=dev

Spring boot - how to modify config properties from an external application

I have a spring boot application and it has an application.yml file that contains a bunch of properties. I am writing a separate test harness for this application and using that application I would like to modify some properties after the main application starts up. I am thinking that I need to add a new REST endpoint that will implement the PUT method and will change the properties. Using that PUT method I should be able to change any property that is defined in the application.yml file. Is that the correct approach. Is there a sample application that I can take a look at.

Resources