|
|
@@ -31,17 +31,18 @@ public class CodeGenerator { |
|
|
|
|
|
|
|
private final String encode = org.apache.commons.codec.CharEncoding.UTF_8; |
|
|
|
//模板文件所在目录 |
|
|
|
private String templatesDir; |
|
|
|
// private String templatesDir; |
|
|
|
|
|
|
|
//模板信息 |
|
|
|
private SwMap mapTemplate; |
|
|
|
|
|
|
|
protected CodeGenerator() { |
|
|
|
templatesDir = this.getClass().getResource("/static/template").getPath(); |
|
|
|
// templatesDir = this.getClass().getResource("/static/template").getPath(); |
|
|
|
mapTemplate = YamlUtil.readValue(this.getClass().getResourceAsStream("/static/template/index.yaml"), SwMap.class); |
|
|
|
configuration = new Configuration(Configuration.VERSION_2_3_31); |
|
|
|
try { |
|
|
|
configuration.setDirectoryForTemplateLoading(new File(templatesDir)); |
|
|
|
configuration.setClassForTemplateLoading(this.getClass(), "/static/template/"); |
|
|
|
// configuration.setDirectoryForTemplateLoading(new File(templatesDir)); |
|
|
|
configuration.setClassicCompatible(true); |
|
|
|
configuration.setDefaultEncoding(encode); |
|
|
|
configuration.setOutputEncoding(encode); |
|
|
|