Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java MySQL密码包含'=';spring boot中存在错误的密码问题_Java_Mysql_Spring Boot - Fatal编程技术网

Java MySQL密码包含'=';spring boot中存在错误的密码问题

Java MySQL密码包含'=';spring boot中存在错误的密码问题,java,mysql,spring-boot,Java,Mysql,Spring Boot,我在我的应用程序中使用SpringBoot,我们有Azure服务用于部署以及MySQL服务 我可以将MySQL与MySQL workbench连接起来,但在部署Spring启动应用程序时出现了错误 Caused by: java.sql.SQLException: Access denied for user 'dev-admin'@'IP' (using password: YES) 我假设如果我的MySQL密码包含'=',那么它在使用Spring Boot部署时会出现问题,因为我更改了密码

我在我的应用程序中使用SpringBoot,我们有Azure服务用于部署以及MySQL服务

我可以将MySQL与MySQL workbench连接起来,但在部署Spring启动应用程序时出现了错误

Caused by: java.sql.SQLException: Access denied for user 'dev-admin'@'IP' (using password: YES)
我假设如果我的MySQL密码包含
'='
,那么它在使用Spring Boot部署时会出现问题,因为我更改了密码并删除了
'='
,它可以工作

但这些都是随机生成的密码,我不确定将来在其他环境部署中密码是否可能包含“=”

我正在application.properties中设置MySQL密码,如下所示

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
spring.datasource.url=jdbc:mysql://hq-dev-xxx-westus-dbserver.mysql.database.azure.com:3306/xxx-发展
spring.datasource.username=dev-admin@dev-hq westus数据库服务器
您可能知道,spring.datasource.password=$AP=5ttfg{(=是一个包含一组键值对的文件

由于Java将第一次出现的=或:视为键值分隔符,因此可以在行中放置反斜杠转义字符()

为了避免错误,最好按如下方式编程构建:

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);
  }
}
import java.io.IOException;
导入java.util.Properties;
公共类TestSO{
公共静态void main(字符串args[])引发IOException{
Properties props=新属性();

props.setProperty(“spring.datasource.password”,“$AP=5ttfg{(=我跳过了“=”字符。谢谢!
#Sat Jul 28 04:05:29 CLT 2018
spring.datasource.password=$AP\=5ttfg{(\=<WN //this line you have to put in your properties file