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

feat: H2数据库脚本执行指定UTF-8字符集,避免在win系统下乱码. #6166

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.SQLException;

/**
* 基础测试类
Expand All @@ -19,12 +18,12 @@ public class BaseGeneratorTest {
/**
* 执行数据库脚本
*/
protected static void initDataSource(DataSourceConfig dataSourceConfig) throws SQLException {
protected static void initDataSource(DataSourceConfig dataSourceConfig) throws Exception {
Connection conn = dataSourceConfig.getConn();
InputStream inputStream = H2CodeGeneratorTest.class.getResourceAsStream("/sql/init.sql");
ScriptRunner scriptRunner = new ScriptRunner(conn);
scriptRunner.setAutoCommit(true);
scriptRunner.runScript(new InputStreamReader(inputStream));
scriptRunner.runScript(new InputStreamReader(inputStream, "UTF-8"));
conn.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.engine.EnjoyTemplateEngine;

import java.sql.SQLException;

/**
* <p>
Expand All @@ -25,7 +22,7 @@ public class FastAutoGeneratorTest extends BaseGeneratorTest {
/**
* 执行 run
*/
public static void main(String[] args) throws SQLException {
public static void main(String[] args) throws Exception {
// 初始化数据库脚本
initDataSource(DATA_SOURCE_CONFIG.build());
FastAutoGenerator.create(DATA_SOURCE_CONFIG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.junit.jupiter.api.Test;

import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -35,7 +34,7 @@ public class H2CodeGeneratorTest extends BaseGeneratorTest {
* 执行初始化数据库脚本
*/
@BeforeAll
public static void before() throws SQLException {
public static void before() throws Exception {
initDataSource(DATA_SOURCE_CONFIG);
}

Expand Down
Loading