springboot整合screw
文档工具screw:
依赖
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.30</version>
</dependency>
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.3</version>
</dependency>
测试
@SpringBootTest
public class ScrewTests {
@Autowired
private ApplicationContext applicationContext;
@Test
void test(){
DataSource dataSource = applicationContext.getBean(DataSource.class);
//生成文件配置
EngineConfig engineConfig = EngineConfig
.builder()
//文件生成路径
.fileOutputDir("G:\\file")
//打开目录
.openOutputDir(false)
//文件类型
.fileType(EngineFileType.HTML)
//生成模板实现
.produceType(EngineTemplateType.freemarker)
.build();
//配置想要生成的表
ProcessConfig processConfig = ProcessConfig
.builder()
//根据名称指定表生成
.designatedTableName(new ArrayList<>())
//根据表前缀生成
.designatedTablePrefix(new ArrayList<>())
//根据表后缀生成
.designatedTableSuffix(new ArrayList<>())
//忽略表名
.ignoreTableName(new ArrayList<>())
//忽略表前缀
.ignoreTablePrefix(new ArrayList<>())
//忽略表后缀
.ignoreTableSuffix(new ArrayList<>())
.build();
//生成文档配置
Configuration configuration = Configuration.builder()
.version("1.0.0")
.description("描述")
.dataSource(dataSource)
.engineConfig(engineConfig)
.produceConfig(processConfig)
.build();
//生成
new DocumentationExecute(configuration).execute();
}
}