一、首先在yml.等的配置文件中配置远程数据库所需要的配置信息
### spring配置
spring:
## 数据库配置
datasource:
pupupu:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://11.111.11.11:3306/库名?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2b8&allowMultiQueries=true
username: root
password: root
二、在代码中获取 .yml配置文件中的数据信息
import org.springframework.beans.factory.annotation.Value;
//对应 @value的包名 ,我也给打出来
@Value("${spring.datasource.pupupu.driver-class-name}")
private String jdbc;
@Value("${spring.datasource.pupupu.jdbc-url}")
p