mysql - Spring Boot 连接 MySQL 远程数据库

标签 mysql spring spring-mvc spring-boot remote-server

我正在 Spring Boot 中开发一个应用程序。我正在使用 phpMyAdmin (在我的大学是免费的)数据库来实现持久性。我的数据库位于远程服务器中。如何配置远程数据库连接的数据源?

请帮助我使用配置类中的注释在属性文件和数据源 bean 配置中进行配置。

例如:登录用户名:admin,密码:root

enter image description here

最佳答案

也许就像

在文件application.properties

spring.datasource.url=jdbc:mysql://lamp.ii.us.edu.pl:3306/ii309808
spring.datasource.username=admin
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

(3306是MySQL数据库管理系统的默认端口号。如果无法通过3306端口连接,请询问您的系统管理员)

引用:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html#boot-features-connect-to-production-database

关于mysql - Spring Boot 连接 MySQL 远程数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50837960/

相关文章:

php - MySQL 数据库中的乱码文本

PHP 脚本未运行也未发布到 mysql

java - Spring , hibernate : Invalid UTF-8 start byte 0x80 error when trying to save images

java - 如何保存request.getAttribute值?

java - 如何为多个身份验证提供者提供 spring security 的 java 配置

php - 为什么会出现这个错误? (将值传递给连接表)

PHP注册表格未连接到数据库

java - Spring MVC : RequestMapping both class and method

spring - 如何从 Spring Boot 中的公共(public)类中获取 session ?

java - 当 Spring Context 中所有 Controller 都准备就绪时,如何触发事件?