Commit c5460253 by chengzhuoshen

1.移除掉无效的jar依赖,并修改相关依赖代码,比如velocity,log相关的pom依赖。

parent dfee5fc4
...@@ -35,29 +35,14 @@ ...@@ -35,29 +35,14 @@
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.4</version> <version>2.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>dom4j</groupId>
<artifactId>velocity</artifactId> <artifactId>dom4j</artifactId>
<version>1.7</version> <version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
......
...@@ -31,8 +31,6 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator { ...@@ -31,8 +31,6 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
this.context = context; this.context = context;
} }
protected String defaultDateTimeFormate = "yyyy-MM-dd HH:mm:ss,SSS";
//TODO //TODO
protected String getRandomNumber(int length) { protected String getRandomNumber(int length) {
String randomNumber = ""; String randomNumber = "";
......
package com.brilliance.swift.mx2mt.mt202cov202.impl.cov; package com.brilliance.swift.mx2mt.mt202cov202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FieldB70Generate extends AbstractMx2MtTagsGenerate { public class FieldB70Generate extends AbstractMx2MtTagsGenerate {
......
package com.brilliance.swift.mx2mt.mt202cov202.impl.cov; package com.brilliance.swift.mx2mt.mt202cov202.impl.cov;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class FieldB72Generate extends AbstractMx2MtTagsGenerate { public class FieldB72Generate extends AbstractMx2MtTagsGenerate {
......
...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt900910.impl; ...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt900910.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Field13DGenerate extends AbstractMx2MtTagsGenerate { public class Field13DGenerate extends AbstractMx2MtTagsGenerate {
......
package com.brilliance.swift.mx2mt.mt900910.impl; package com.brilliance.swift.mx2mt.mt900910.impl;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import com.brilliance.swift.util.StringUtil;
import org.dom4j.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <GrpHdr><MsgId> * <GrpHdr><MsgId>
......
...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt900910.impl; ...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt900910.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <Ntfctn><Ntry><NtryDtls><TxDtls><Refs><EndToEndId> * <Ntfctn><Ntry><NtryDtls><TxDtls><Refs><EndToEndId>
......
...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt940950.impl; ...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <Stmt><Acct><Id><IBAN> * <Stmt><Acct><Id><IBAN>
......
...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt940950.impl; ...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <GrpHdr><MsgPgntn><PgNb> * <GrpHdr><MsgPgntn><PgNb>
......
...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt940950.impl; ...@@ -2,8 +2,6 @@ package com.brilliance.swift.mx2mt.mt940950.impl;
import com.brilliance.swift.exception.SwiftException; import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate; import com.brilliance.swift.mx2mt.AbstractMx2MtTagsGenerate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd> * <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package com.brilliance.swift.util; package com.brilliance.swift.util;
import com.brilliance.swift.exception.CommonRuntimeException; import com.brilliance.swift.exception.CommonRuntimeException;
import org.apache.commons.lang.ClassUtils;
import java.io.Closeable; import java.io.Closeable;
import java.io.Externalizable; import java.io.Externalizable;
...@@ -134,7 +133,7 @@ public abstract class ClassUtil { ...@@ -134,7 +133,7 @@ public abstract class ClassUtil {
} }
if (cl == null) { if (cl == null) {
// No thread context class loader -> use class loader of this class. // No thread context class loader -> use class loader of this class.
cl = ClassUtils.class.getClassLoader(); cl = ClassUtil.class.getClassLoader();
if (cl == null) { if (cl == null) {
// getClassLoader() returning null indicates the bootstrap ClassLoader // getClassLoader() returning null indicates the bootstrap ClassLoader
try { try {
......
...@@ -2,7 +2,6 @@ package com.brilliance.swift.util; ...@@ -2,7 +2,6 @@ package com.brilliance.swift.util;
import com.brilliance.swift.exception.IORuntimeException; import com.brilliance.swift.exception.IORuntimeException;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
...@@ -78,7 +77,7 @@ public class FileUtil { ...@@ -78,7 +77,7 @@ public class FileUtil {
public static URI toURI(String location) { public static URI toURI(String location) {
try { try {
return new URI(StringUtils.replace(location, " ", "%20")); return new URI(location.replace(" ", "%20"));
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("URI转换异常:" + e.getMessage(), e); throw new IllegalArgumentException("URI转换异常:" + e.getMessage(), e);
} }
......
...@@ -2,7 +2,6 @@ package com.brilliance.swift.util; ...@@ -2,7 +2,6 @@ package com.brilliance.swift.util;
import com.brilliance.swift.constants.Mx2MtConstants; import com.brilliance.swift.constants.Mx2MtConstants;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -369,7 +368,7 @@ public abstract class StringUtil { ...@@ -369,7 +368,7 @@ public abstract class StringUtil {
* @throws * @throws
*/ */
public static String getStringByEnter(String string, int length, int rows) { public static String getStringByEnter(String string, int length, int rows) {
if (StringUtils.isEmpty(string)) if (StringUtil.isEmpty(string))
return string; return string;
if (--rows <= 0) { if (--rows <= 0) {
return string.length() > length ? string.substring(0, length) : string; return string.length() > length ? string.substring(0, length) : string;
......
package com.brilliance.swift.util;
import com.brilliance.swift.exception.SwiftException;
import org.apache.commons.io.FileUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
import java.util.Map;
/**
* 通过模型类将模板转成字符串
*
* **/
public class TemplateUtil {
/**
* 通过模型生成函数将模板转成字符串
* @Param String template 模板名称
* @Param cache 模板变量Map集合
* @Param outPut 文件输出保存路径
* @Param encode 文件生成编码
* @Return string 返回生成的文件字符串
* **/
public static String makeFileByTemplate(String template, Map<String, Object> cache, String outPut, String encode) {
String lastStr="";
ClassLoader classLoader = TemplateUtil.class.getClassLoader();
URL url = classLoader.getResource("template/");
if (url != null) {
VelocityEngine ve = new VelocityEngine();
try {
ve.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, url.toURI().getPath());
ve.setProperty(Velocity.OUTPUT_ENCODING, encode);
ve.setProperty(Velocity.INPUT_ENCODING, encode);
ve.init();
VelocityContext context = new VelocityContext();
Template vt = ve.getTemplate(template);
context.put("vm", cache);
StringWriter sw = new StringWriter();
vt.merge(context, sw);
lastStr=sw.toString();
if (!StringUtil.isEmpty(outPut)) {
FileUtils.write(new File(outPut),lastStr.replaceAll("\\\\\\\\", "\\$"), encode, false);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
} else {
}
return lastStr;
}
public static void makeFileByTemplate2(String template, Map<String, Object> cache, String outPut, String encode) throws IOException {
ClassLoader classLoader = TemplateUtil.class.getClassLoader();
URL url = classLoader.getResource("template/");
if (url != null) {
VelocityEngine ve = new VelocityEngine();
ve.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, url.getPath());
ve.setProperty(Velocity.OUTPUT_ENCODING, encode);
ve.setProperty(Velocity.INPUT_ENCODING, encode);
ve.init();
VelocityContext context = new VelocityContext();
Template vt = ve.getTemplate(template);
for (String key : cache.keySet()) {
context.put(key, cache.get(key));
}
StringWriter sw = new StringWriter();
vt.merge(context, sw);
FileUtils.write(new File(outPut), sw.toString().replaceAll("\\\\\\\\", "\\$"), encode, false);
} else {
throw new FileNotFoundException("没有在template目录下找到模板文件:" + template);
}
}
public static void main(String[] args) throws Exception {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment