具有 Mysql 数据库和 Microsoft Azure 的 Spring Boot 应用程序

Spring Boot App with Mysql database and Microsoft Azure

提问人:BHeiB 提问时间:7/24/2021 最后编辑:BHeiB 更新时间:7/27/2021 访问量:277

问:

我在Azure上使用MySql部署Spring Boot应用程序几乎没有问题。当我使用 Eclipse 时一切正常,但是当我在 Microsoft Azure 上部署时,部署以成功结束,但我得到

2021-07-24T09:30:20.876358957Z 2021-07-24 09:30:20.875  INFO 124 --- [           main] 
o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2021-07-24T09:30:21.830327807Z 2021-07-24 09:30:21.774  INFO 124 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-07-24T09:30:22.672309649Z 2021-07-24 09:30:22.605 ERROR 124 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.
2021-07-24T09:30:22.672341649Z 
2021-07-24T09:30:22.672346649Z com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
2021-07-24T09:30:22.672349949Z 
2021-07-24T09:30:22.672352949Z The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2021-07-24T09:30:22.672356349Z  at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql- 
  connector-java-8.0.18.jar!/:8.0.18]
  2021-07-24T09:30:22.672360049Z    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.18.jar!/:8.0.18]

当我尝试进入应用程序时。我使用了很多教程,因为我不知道Azure,但这个解决方案对我的问题没有帮助。如果知道这个异常,我的application.properties中的url地址有问题。

spring.datasource.url=jdbc:mysql://{name of database server}.mysql.database.azure.com:3306/{name of scheme}?useSSL=false&useLegacyDateTimeCode=false&serverTimezone=CET
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username={login}@{name my database server}
spring.datasource.password={my password}

你是什么意思?

java mysql spring azure 连接

评论

0赞 Saurabh Singh 7/24/2021
从上面看,您的应用程序似乎无法与MySQL服务器建立通信。您能否尝试检查运行应用程序的容器是否打开了外部端口以与正在运行的容器之外的组件进行交互?
0赞 BHeiB 7/25/2021
对不起,我该怎么做?
0赞 muhammed ozbilici 7/25/2021
@BHeiB使用命令输入容器,然后尝试使用或命令连接MySQL IP地址。docker exectelnetcurl
0赞 BHeiB 7/25/2021
我是 Azure 中的最新成员,我不知道我是如何进行您的指导的。如果我的意思是我必须在我的系统上安装 Docker?还是在 Azure 门户上使用 Azure CLI?

答: 暂无答案