通过java实现
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
spring.datasource.url=jdbc:mysql://192.168.1.101:3306/ssm?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.freemarker.checkTemplateLocation=false
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.suffix=.ftl
spring.freemarker.enabled=true
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.allow-request-override=false
spring.freemarker.check-template-location=true
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
@Autowired
ApplicationContext applicationContext;
@GetMapping("/db")
public String contextLoads() {
DataSource dataSourceMysql = applicationContext.getBean(DataSource.class);
EngineConfig engineConfig = EngineConfig.builder()
.fileOutputDir("C:\\Users\\EDZ\\Desktop\\1115")
.openOutputDir(false)
.fileType(EngineFileType.WORD)
.produceType(EngineTemplateType.freemarker).build();
Configuration config = Configuration.builder().version("1.0.3").description("生成文档信息描述")
.dataSource(dataSourceMysql).engineConfig(engineConfig).produceConfig(getProcessConfig()).build();
new DocumentationExecute(config).execute();
return "s";
}
public static ProcessConfig getProcessConfig() {
List<String> ignoreTableName = Arrays.asList("aa", "test_group");
List<String> ignorePrefix = Arrays.asList("ts_", "xc_", "safe_");
List<String> ignoreSuffix = Arrays.asList("_test", "czb_");
ArrayList<String> zk = new ArrayList<>();
zk.add("xc_dictionary");
return ProcessConfig.builder()
.designatedTableName(zk)
.designatedTablePrefix(new ArrayList<>())
.designatedTableSuffix(new ArrayList<>()).build();
}