This question is not about escaping characters such as = or " in the property. The questions are:
- How do I get the expected values, e.g. for the password I want
DE#Fand notDE - More academically; why is this happening?
(I assume) Spring is not reading in the environment variables correctly that contains an # in the string - on Linux. E.g.:
The yml file:
# Spring Boot configuration in yml file
application:
username: Clark Kent
password: abc
The overriding environmental variable in /etc/environment
APPLICATION_USERNAME="Ronald Raygan" #Maybe use a stronger password?
APPLICATION_PASSWORD="DE#F"
In the application, the following values are used:
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
public class ApplicationProperties {
private String username;
private String password;
// rest of the class
}
In another class:
System.out.println(applicationProperties.getUsername());
System.out.println(applicationProperties.getPassword());
This will print out:
Ronald Raygan"
DE