项目结构:
image.png
开发工具:IDEA Ultimate
过程:
1.打开IDEA
点击:
File-New-Project from Existing Sources
image.png
2.选择项目文件中的pom.xml,点击OK
image.png3.一路next
image.pngimage.png
image.png
4.等待项目导入成功后,配置run 方式点击右上角的
image.png点击+号,选择maven
image.png
在 Command line 填上tomcat7:run,点击ok,完成配置
image.png
5.修改数据库连接配置
打开/src/main/resources/properties/jeeplus.properties
修改mysql数据库配置
#mysql database setting
jdbc.type=mysql
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/gymnasium?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=shine2015
jdbc.testSql=SELECT 'x'
jdbc.dual =
6.运行项目
运行前准备:
1.启动redis服务
image.png
错误:
1.没有启动redis服务
image.png
2.一直报错:
image.png
排错历程:
1.起初以为是/src/main/resources/properties/jeeplus.properties
里的mysql配置不正确,多次修改还是出现问题
2.怀疑 数据库gymnasium 导入出现问题
多次用Navicat for MySQL 导入数据库,运行项目还是报错
3.然后怀疑是用idea 导入项目 出现问题
尝试使用eclipse导入项目,
4.建新帮忙查找问题,他使用IDEA导入项目 运行没问题,mysql的版本是5.5,我的mysql版本是8.0
5.重新安装mysql5.7 后,运行项目就没问题了
总结:
错误原因: mysql数据库版本8 ,项目的jdbc驱动不支持
参考:https://blog.csdn.net/wanglong1221/article/details/81148146
1、驱动包要升级为 mysql-connector-java-8.0.11.jar
2、JDBC driver 由“com.mysql.jdbc.Driver”改为“com.mysql.cj.jdbc.Driver”
3、url中加上“userSSL=false”。否则会出现以下错误:
“Establishing SSL connection withoutserver's identity verification is not recommended. According to MySQL 5.5.45+,5.6.26+ and 5.7.6+ requirements SSL connection must be established by defaultif explicit option isn't set. For compliance with existing applications notusing SSL the verifyServerCertificate property is set to 'false'. You needeither to explicitly disable SSL by setting useSSL=false, or set useSSL=trueand provide truststore for server certificate verification.”
4、url中加上“serverTimezone=GMT%2B8”(
GMT%2B8
代表东八区)或者直接修改数据库的默认时区:
show variables like '%time_zone%';set global time_zone='+8:00';
最后附示例URL:
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&userSSL=false&serverTimezone=GMT%2B8
网友评论