public static void main(String[] args) throws Exception { System.out.println(repeat("-", 80)); for (String line : readLines(getResource("banner.txt"), Charsets.UTF_8)) { System.out.println(line); } String version = ComputeCommandLine.class.getPackage().getImplementationVersion(); System.out.println("Version: " + (version != null ? version : "DEVELOPMENT")); System.out.println(repeat("-", 80)); // disable freemarker logging freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE); // parse options ComputeProperties computeProperties = new ComputeProperties(args); new ComputeCommandLine().execute(computeProperties); }
@SuppressWarnings("deprecation") private static synchronized void init() throws Exception { Version version = new Version(2, 3, 23); Logger.selectLoggerLibrary(0); cfg = new Configuration(version); // cfg.setLogTemplateExceptions(true); cfg.setCacheStorage(new MruCacheStorage(0, Integer.MAX_VALUE)); cfg.setObjectWrapper(new DefaultObjectWrapper(version)); // cfg.setDirectoryForTemplateLoading(new // File(FreemarkerUtil.class.getClassLoader().getResource("template").getFile() )); // cfg.setClassForTemplateLoading(FreemarkerUtil.class, "template"); StringTemplateLoader st = new StringTemplateLoader(); // st.putTemplate("autoMall", // "<AutoMall><docid>${autoMall.docid!}</docid><Id>${autoMall.id!}</Id><Name><![CDATA[${autoMall.name!}]]></Name><NameAlias><![CDATA[${autoMall.nameAlias!}]]></NameAlias><ImgUrl><![CDATA[${autoMall.imgUrl!}]]></ImgUrl><CarStyleId>${autoMall.carStyleId!}</CarStyleId><CategoryId>${autoMall.categoryId!}</CategoryId><CategoryLevel>${autoMall.categoryLevel!}</CategoryLevel><BrandId>${autoMall.brandId!}</BrandId><SpecificationsId>${autoMall.specificationsId!}</SpecificationsId><FactoryNumber>${autoMall.factoryNumber!}</FactoryNumber><ShelvesTime>${autoMall.shelvesTime!}</ShelvesTime><RegionId>${autoMall.regionId!}</RegionId><IsHstock>${autoMall.isHstock!}</IsHstock><IsCerGoods>${autoMall.isCerGoods!}</IsCerGoods><IsStarProducts>${autoMall.isStarProducts!}</IsStarProducts><SalesVolume>${autoMall.salesVolume!}</SalesVolume><Evaluation>${autoMall.evaluation!}</Evaluation><Price>${autoMall.price!}</Price><GoodsModel><![CDATA[${autoMall.goodsModel!}]]></GoodsModel><UserDefinedBrandName><![CDATA[${autoMall.userDefinedBrandName!}]]></UserDefinedBrandName><FactoryName><![CDATA[${autoMall.factoryName!}]]></FactoryName><CarStyleName><![CDATA[${autoMall.carStyleName!}]]></CarStyleName><ServiceStationName><![CDATA[${autoMall.serviceStationName!}]]></ServiceStationName><StoreId>${autoMall.storeId!}</StoreId><StoreName><![CDATA[${autoMall.storeName!}]]></StoreName><AttrValue><![CDATA[${autoMall.attrValue!}]]></AttrValue><CarName><![CDATA[${autoMall.carName!}]]></CarName><BrandName><![CDATA[${autoMall.brandName!}]]></BrandName></AutoMall>"); String[] templates = new String[] {"carParts", "stores", "storesrecomm"}; for (String template : templates) { st.putTemplate(template, CommonUtil.readFileInJar("/template/" + template)); } cfg.setTemplateLoader(st); }