Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Mac运行下报错 #9

Open
Cantoria opened this issue Jul 8, 2018 · 2 comments
Open

在Mac运行下报错 #9

Cantoria opened this issue Jul 8, 2018 · 2 comments

Comments

@Cantoria
Copy link

Cantoria commented Jul 8, 2018

本人运行环境:macos 10.13.4,Intellij,mysql5.7,用JUnit测试(代码mysql部分)时报了一堆错
后来改动了三个地方:
1、按照readme中所述的配置mysql用户名密码,并在mysql中输入grant命令
2、pom.xml文件中增加mysql中JDBC的version

        <groupId>mysql</groupId>            
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.11</version>
        <scope>runtime</scope>

3、mysql改动编码配置:编码需要全部转化为utf-8格式。参考链接https://blog.csdn.net/xiongqiangwin1314/article/details/76983977
注意,改完编码后需要把之前建立的test数据库drop之后再重新create

就可以成功运行了。

@chenfromsz
Copy link
Owner

不用更改任何代码,使用mysql 5.7,运行mysqlTest,经过测试是可以的:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 66249
Server version: 5.7.19 MySQL Community Server (GPL)
。。。。
16:03:18.442 [main] INFO dbdemo.mysql.test.MysqlTest - ====user==== user name:user, department name:开发部, role name:admin

上面是我在mac os 10.12.5中的测试结果。

如果升级了spring boot版本之后,连接数据源的配置中如果安全验证报错可以要加上“&useSSL=false”

@Cantoria
Copy link
Author

Cantoria commented Jul 8, 2018

在debug中看到了 @chenfromsz 所述的warning,在test/JpaConfigration.java中的dataSource方法中,由
dataSource.setUrl("jdbc:mysql://localhost:3306/test?characterEncoding=utf8");
变为
dataSource.setUrl("jdbc:mysql://localhost:3306/test?characterEncoding=utf8&useSSL=false");
即可解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants