spring boot 使用mybatis连接华为云MySQL数据库

spring boot使用mybatis连接MySQL:

applicationg.yml设置:

  spring:

  datasource:
url: jdbc:mysql://***.*.***.***:3306/socks?useSSL=false
username: root
password: *******
driver-class-name: com.mysql.cj.jdbc.Driver

mybatis:
configuration:
map-underscore-to-camel-case: true #开启驼峰映射

启动类中添加@MapperScan(),解决启动时找不到bean的问题
@MapperScan("com.***.***.mapper")
华为云绑定公网IP后连接超时的问题:
在华为云安全组-添加入向规则,增加3306端口,允许所有IP访问
连接后提示无权限访问:
Access denied for user 'root'@'***.***.***.***' (using password: YES)

在Mysql数据库中执行以下语句放开root用户的外网访问权限
grant all privileges on *.* to root@'%' identified by '******' //***表示数据库连接密码

猜你喜欢

转载自www.cnblogs.com/xiaojwang/p/12152255.html
今日推荐