平时多积累一些好工具,才能提高工作效率,早点下班
1. 关键字百度
2.拉取,运行
2.1 idea识别、导入maven工具
2.2 下载完依赖,修改数据库账号密码等,再到启动类,发现报红
- 指定工程jdk
2.3 启动成功,调用接口生成文档
-
浏览器请求接口:http://localhost:8080/api/tableToWord
-
只有标题
-
追根溯源:controller–>service–>mapper
-
指定了数据库名称
2.4 修改数据库名称,生成成功
3. 如果是mysql8.0
- ERROR 18716 — [reate-900824070] com.alibaba.druid.pool.DruidDataSource:
create connection error,…, errorCode 0, state 01S00
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <version>5.1.40</version> -->
<mysql.version>8.0.16</mysql.version>
</dependency>
- java.sql.SQLException: The server time zone value ‘…��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
# 配置数据源
datasource:
#url: jdbc:mysql://127.0.0.1:3306/demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull&useSSL=false # MySQL在高版本需要指明是否进行SSL连接 解决则加上 &useSSL=false
url: jdbc:mysql://127.0.0.1:3306/demo?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&nullCatalogMeansCurrent=true
# driver-class-name: com.mysql.jdbc.Driver
# com.mysql.jdbc.Driver和mysql-connector-java 5一起用
# com.mysql.cj.jdbc.Driver和mysql-connector-java 6+ 一起用
driver-class-name: com.mysql.cj.jdbc.Driver
-
调用接口报错:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/lowagie/text/rtf/RtfWriter2] with root cause
-
原因:找不到com.lowagie.text.rtf.RtfWriter2,该类不在com.lowagie.text包下,在itext-rtf
-
注意:2.1.7版本以上的com.lowagie.text 由于合并问题,maven会自动下载itextpdf包
-
解决办法:将共用的本地maven仓库清空(可能会彼此冲突),重新下载依赖,或者给当前项目指定独有的maven本地仓库