How to set environment variables in the properties file of Spring boot application

keyword: PropertyPlaceholder It seems that you can do various things, but this time I want to use the environment variables set on the server after deploying. It's easy to write. Rewrite as below and you're done.

spring.datasource.url=jdbc:mysql://localhost:3306/test
↓
spring.datasource.url=jdbc:mysql://${RDS_DB_HOST}:${RDS_DB_PORT}/${RDS_DB_NAME}

When running from Eclipse, either VM arguments or Programe arguments seems to be okay.

VM_arguments


-DRDS_DB_HOST=localhost
-DRDS_DB_PORT=3306
-DRDS_DB_NAME=test

Programe_arguments


--RDS_DB_HOST=localhost
--RDS_DB_PORT=3306
--RDS_DB_NAME=test

Recommended Posts

How to set environment variables in the properties file of Spring boot application
How to bind to property file in Spring Boot
[Spring Boot] How to refer to the property file
Procedure to make the value of the property file visible in Spring Boot
How to boot by environment with Spring Boot of Maven
Put the file in the properties of string in spring xml configuration
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
Fix the file name of war to the one set in Maven
How to use environment variables in RubyOnRails
How to split Spring Boot message file
How to get the length of an audio file in java
How to set the indent to 2 single-byte spaces in the JAXB implementation of the JDK
[Spring Boot] I investigated how to implement post-processing of the received request.
The story of raising Spring Boot 1.5 series to 2.1 series
How to add a classpath in Spring Boot
Spring Boot --How to set session timeout time
How to check the latest version of io.spring.platform to describe in pom.xml of Spring (STS)
Sign in to a Spring Boot web application on the Microsoft ID platform
[Spring Boot] How to get properties dynamically from a string contained in a URL
How to set the display time to Japan time in Rails
05. I tried to stub the source of Spring Boot
How to create a Spring Boot project in IntelliJ
I tried to reduce the capacity of Spring Boot
[Java] Get the file in the jar regardless of the environment
How to test file upload screen in Spring + Selenium
How to debug the generated jar file in Eclipse
Set context-param in Spring Boot
How to set the log level to be displayed in the release version of orhanobut / logger
How to use git with the power of jgit in an environment without git commands
How to check the WEB application created in the PC development environment on your smartphone
Summary of how to use the proxy set in IE when connecting with Java
How to correctly check the local HTML file in the browser
The story of raising Spring Boot from 1.5 series to 2.1 series part2
How to set environment variables when using Payjp with Rails
How to change application.properties settings at boot time in Spring boot
How to set chrony when the time shifts in CentOS7
[Java] Deploy the Spring Boot application to Azure App Service
Extract SQL to property file with jdbcTemplate of spring boot
Deploy the application created by Spring Boot to Heroku (public) ②
How to set and describe environment variables using Rails zsh
How to call and use API in Java (Spring Boot)
Set the time zone in the JVM of your Azure application
How to derive the last day of the month in Java
How to change the contents of the jar file without decompressing
Set up Multipart Resolver to allow file uploads in Spring
How to control transactions in Spring Boot without using @Transactional
When I switched to IntelliJ, I got a lot of differences in the encoding of the properties file.
How to specify an array in the return value / argument of the method in the CORBA IDL file
How to use the same Mapper class in multiple data sources with Spring Boot + MyBatis
How to manage the difference in each environment with yml without increasing the number of RAILS_ENV
I want to control the maximum file size in file upload for each URL in Spring Boot
Let's find out how to receive in Request Body with REST API of Spring Boot
How to use Lombok in Spring
Spring Boot application development in Eclipse
Implement Spring Boot application in Gradle
How to use ModelMapper (Spring boot)
How to name variables in Java
How to set Lombok in Eclipse
It doesn't respond to the description in .js of the packs file
[Sprint Boot] How to use 3 types of SqlParameterSource defined in org.springframework.jdbc.core.namedparam
How to set the IP address and host name of CentOS8