Spring boot application.properties extends another property file

skumar

I have few properties in one property file which I want to inherit to application properties. Please let know if that is possible in spring boot.

something like

application.properties
----------------------
extends = otherproperty.properties
property1 = value1
property2= value2
property3 = value3

otherproperty.properties
------------------------
property4=value4
property5 = value5

When the spring boot app loads, I want all 5 properties should be loaded and available using @Value annotation. The spring boot automatically picks the application.properties in classpath and I don't have applicaitoncontext xml or any property loader code.

Thanks in advance.

mentalo

I had the same question and found a good explained solution by mkyong. The tutorial explains how you can use different extending Spring profiles by using .porperties or .yaml files. (Same approach like eSala mentioned.)

https://www.mkyong.com/spring-boot/spring-boot-profile-based-properties-and-yaml-example/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

spring boot adding another properties file to the environment

Spring Boot not recognizing application.properties file

How to directly read application.property value into another configuration xml file in spring boot

Prevent overriding some property in application.properties - Spring Boot

Spring Boot - property could not be resolved in xml from application.properties

How to set value to a property present in application.properties for Spring boot

Environment Specific application.properties file in Spring Boot application

Conveniently and temporarily modify a Spring property in an application.properties file

Using a Jenkins variable in application properties file of spring boot app

Load Spring Boot application properties from external file

Where is the application.properties file in a Spring Boot project?

How to externalize a url in Spring Boot to application.properties file?

How to access a value defined in the application.properties file in Spring Boot

Programatically changing the application.properties file at runtime with Spring Boot

not able to read application.properties file in Spring boot Java

Why is ! in the properties file path in spring-boot application on the docker?

Deploy Spring Boot app to Heroku with a particular application.properties file

How to set file location in application properties - Spring boot

Why is Spring Boot not reading from default application.properties file

@Value annotation unable to read properties file in spring boot camel application

Spring Boot - Do not resolve placeholders in the application.properties file

Oracle db logger into Spring Boot application.properties file

How to access defined in the application.properties file in Spring Boot?

Encrypting application properties in Spring Boot

Spring Boot command line property not overriding property defined in application.properties

How do I set MyBatis configuration properties in an application.properties file in a Spring Boot application?

Can I use xml properties file instead of application.properties in a Spring Boot application?

I want to write a property to application.properties before spring boot application start

In which class in the source code of spring-boot or spring is the application.yml or application.properties file processed?