Accumulate more good tools at ordinary times to improve work efficiency and get off work early
1. Keyword Baidu
Java export database table information to generate Word document
2. Pull and run
2.1 idea identification, import maven tool
2.2 After downloading the dependencies, modify the database account password, etc., and then go to the startup class, and find that the report is red
- Specify project jdk
2.3 The startup is successful, and the interface is called to generate the document
-
Browser request interface: http://localhost:8080/api/tableToWord
-
title only
-
Tracing the source: controller–>service–>mapper
-
The database name is specified
2.4 Modify the database name and generate successfully
3. If it is 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
-
Reason: com.lowagie.text.rtf.RtfWriter2 cannot be found, this class is not under the com.lowagie.text package, but in itext-rtf
-
Note: maven will automatically download the itextpdf package for com.lowagie.text version 2.1.7 and above due to merging issues
-
Solution: Clear the shared local maven warehouse (may conflict with each other), re-download dependencies, or specify a unique maven local warehouse for the current project