use of com.jfinal.template.source.ClassPathSourceFactory in project jboot by yangfuhai.
the class JbootServiceImplGenerator method generate.
public void generate(List<TableMeta> tableMetas) {
System.out.println("Generate Service Impl ...");
System.out.println("Service Impl Output Dir: " + outputDir);
Engine engine = Engine.create("forServiceImpl");
engine.setSourceFactory(new ClassPathSourceFactory());
engine.addSharedMethod(new StrKit());
engine.addSharedObject("getterTypeMap", getterTypeMap);
engine.addSharedObject("javaKeyword", JavaKeyword.me);
for (TableMeta tableMeta : tableMetas) {
genBaseModelContent(tableMeta);
}
writeToFile(tableMetas);
}
use of com.jfinal.template.source.ClassPathSourceFactory in project jboot by yangfuhai.
the class JbootServiceInterfaceGenerator method generate.
@Override
public void generate(List<TableMeta> tableMetas) {
System.out.println("Generate base model ...");
System.out.println("Base Model Output Dir: " + baseModelOutputDir);
Engine engine = Engine.create("forService");
engine.setSourceFactory(new ClassPathSourceFactory());
engine.addSharedMethod(new StrKit());
engine.addSharedObject("getterTypeMap", getterTypeMap);
engine.addSharedObject("javaKeyword", javaKeyword);
for (TableMeta tableMeta : tableMetas) {
genBaseModelContent(tableMeta);
}
writeToFile(tableMetas);
}
use of com.jfinal.template.source.ClassPathSourceFactory in project mica by lets-mica.
the class ActiveRecordConfiguration method activeRecordPlugin.
@Bean
public ActiveRecordPlugin activeRecordPlugin(IDataSourceProvider dataSourceProvider, Environment environment, ResourceLoader resourceLoader, MicaActiveRecordProperties properties, ObjectProvider<List<ActiveRecordPluginCustomizer>> arpCustomizerProvider) {
String modelPackage = properties.getModelPackage();
Assert.hasText(modelPackage, "mica.activerecord.model-package is blank.");
ActiveRecordPlugin arp = new ActiveRecordPlugin(dataSourceProvider);
arp.setDialect(properties.getDialect().getDialect());
arp.setTransactionLevel(properties.getTransactionLevel().getLevel());
arp.setShowSql(false);
// 加载 sql 模板
String[] sqlTemplates = properties.getSqlTemplates();
if (StrKit.notBlank(sqlTemplates)) {
Engine engine = arp.getEngine();
engine.setBaseTemplatePath(properties.getBaseTemplatePath());
engine.setSourceFactory(new ClassPathSourceFactory());
Arrays.stream(sqlTemplates).forEach(arp::addSqlTemplate);
}
// 扫描和添加表映射
if (properties.isAutoTableScan()) {
scanTable(arp, environment, resourceLoader, modelPackage);
}
// arp 自定义配置 bean
arpCustomizerProvider.ifAvailable(customizers -> customizers.forEach(customizer -> customizer.customize(arp)));
arp.start();
return arp;
}
use of com.jfinal.template.source.ClassPathSourceFactory in project ieasy-server by baayso.
the class ViewConfig method jFinalViewResolver.
/**
* Enjoy Template Engine(https://www.jfinal.com/doc/6-1)
*/
@Bean
public JFinalViewResolver jFinalViewResolver() {
JFinalViewResolver jfr = new JFinalViewResolver();
// setDevMode 配置放在最前面
jfr.setDevMode(log.isDebugEnabled());
// 使用 ClassPathSourceFactory 从 class path 与 jar 包中加载模板文件
jfr.setSourceFactory(new ClassPathSourceFactory());
// 在使用 ClassPathSourceFactory 时要使用 setBaseTemplatePath() 代替 jfr.setPrefix("/templates/")
JFinalViewResolver.engine.setBaseTemplatePath("/templates/");
jfr.setSuffix(".html");
jfr.setContentType("text/html;charset=UTF-8");
jfr.setOrder(0);
jfr.addSharedFunction("common/layout.html");
jfr.addSharedFunction("common/main.html");
jfr.addSharedFunction("common/header.html");
jfr.addSharedFunction("common/menu.html");
jfr.addSharedFunction("common/footer.html");
return jfr;
}
Aggregations