Call Spring Boot Application Property From Other Property Or Java VM Option

Sha

I have a property like below in Spring Boot application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/my_db?serverTimezone=UTC&connectTimeout=10000&socketTimeout=30000

In here, I want to give "connectTimeout=10000&socketTimeout=30000" arguments with other properties like:

db.myprops=connectTimeout=10000&socketTimeout=30000
spring.datasource.url=jdbc:mysql://localhost:3306/my_db?serverTimezone=UTC&{db.myprops}

How can I handle it or Is there a specific properties in Spring Boot for connectTimeout and socketTimeout?

Cœur

Solution by OP.

To call it as other property in Spring-Boot Configuration:

spring.application.property.1=property1
spring.application.property.2=property2${spring.application.property.1}

Then we can call it from Java environment to customize it like below:

java -Dspring.application.property.1=custom -jar ../*.jar

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

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

Spring Boot 2.1 : Not loading property from application-test.yml

Spring Boot Application java -jar --property override not working

Spring Boot 2.0 JNDI property values not loading from application-test property file

Configure mongodb property maxWaitQueueSize in Spring boot application?

Using application property in Spring Boot annotation?

how to set system property in spring boot application

Spring Boot not reading from property file

spring boot property with profile from dependency

Dockerfile Spring Boot property from variable not working

how to read from property file in spring boot

Get the value of a property of an object Spring Boot Java

log4j2 spring boot lookup can't read property from application.properties

How to get a value from application.properties in Spring Boot with a component in a service to encrypt a property in a entity

Spring Boot failed to load property source from location 'classpath:/application.xml'

Unable to read property from application.yml using @Value in Spring boot

Access property pf application.properties in outer Spring Boot Java Project

Spring Boot property in @Preauthorize

Setting profiles in Spring Boot application based on system property

Prevent overriding some property in application.properties - Spring Boot

Spring Boot CRUD Application with Thymeleaf -UTF-8 in property files

Spring boot + gradle pass comand line args to application.property

@NotNull constraint don't work for a application property value spring boot

Multiple property files for same Spring Boot Application based on request

Spring boot application.properties extends another property file

Hibernate set property access strategy on whole Spring Boot application

How to read a property on a static field in a spring-boot application?

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

How to read spring boot application property information inside the library