Reputation: 1435
I am using Spring boot in my application and we have Azure Services for deployment as well for MySQL services.
I can connect MySQL with MySQL workbench but it gives me error while deploying the Spring boot application that
Caused by: java.sql.SQLException: Access denied for user 'dev-admin'@'IP' (using password: YES)
I assume if my MySQL password contains '='
then it is having issue while deployment with Spring Boot because I changed my password and removed '='
and it works.
But those are random generated password and I am not sure if the password may contain '=' in future with other environment deployment.
I am setting MySQL password in application.properties like this
spring.datasource.url=jdbc:mysql://hq-dev-xxx-westus-dbserver.mysql.database.azure.com:3306/xxx-dev
spring.datasource.username=dev-admin@dev-hq-westus-dbserver
spring.datasource.password=$AP=5ttfg{(=<WN
So my question is how can I assign password having '='?
Upvotes: 0
Views: 653
Reputation: 1997
As you may know Properties Class is a file with a set of key value pairs.
as Java treats the first occurrence of = or : as the key-value delimiter you may put backslash escape character () in your line.
In order to avoid errors, it's a good practice to build it programatically like this:
import java.io.IOException;
import java.util.Properties;
public class TestSO {
public static void main(String args[]) throws IOException{
Properties props = new Properties();
props.setProperty("spring.datasource.password", "$AP=5ttfg{(=<WN");
props.store(System.out, null);
}
}
That would print the correct property assignment:
#Sat Jul 28 04:05:29 CLT 2018
spring.datasource.password=$AP\=5ttfg{(\=<WN //this line you have to put in your properties file
Upvotes: 1