平时多积累一些好工具,才能提高工作效率,早点下班
Java 导出数据库表信息生成Word文档
gitee地址
浏览器请求接口:http://localhost:8080/api/tableToWord
只有标题
追根溯源:controller–>service–>mapper
指定了数据库名称
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <!-- <version>5.1.40</version> --> <mysql.version>8.0.16</mysql.version> </dependency>
# 配置数据源 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本地仓库