生成代码时只清理前面的空白字符

This commit is contained in:
makejava 2020-12-31 14:20:36 +08:00
parent cb05af50cb
commit 1fb049e96b
1 changed files with 5 additions and 1 deletions

View File

@ -149,7 +149,11 @@ public class CodeGenerateServiceImpl implements CodeGenerateService {
// 开始生成
String code = VelocityUtils.generate(template.getCode(), param);
// 清除前面空格
code = code.trim();
StringBuilder sb = new StringBuilder(code);
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
sb.deleteCharAt(0);
}
code = sb.toString();
// 设置一个默认保存路径与默认文件名
if (StringUtils.isEmpty(callback.getFileName())) {
callback.setFileName(tableInfo.getName() + "Default.java");