Open simplecode101 opened 1 year ago
你可以把读取yaml配置那个方法readConfigurationFromFile替换为这个
private static void readConfigurationFromFile() {
try {
URL url = ConfigUtil.class.getClassLoader().getResource("generator.yaml");
if (null == url || url.getPath().contains("jar")) {
System.err.println("Can not find file named 'generator.yaml' under resources path, please make sure that you have defined that file.");
System.exit(0);
} else {
Yaml yaml = new Yaml(new Constructor(Configuration.class));
InputStream inputStream = ConfigUtil.class.getClassLoader().getResourceAsStream("generator.yaml");
ConfigUtil.setConfiguration(yaml.load(inputStream));
}
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
你可以把读取yaml配置那个方法readConfigurationFromFile替换为这个
private static void readConfigurationFromFile() { try { URL url = ConfigUtil.class.getClassLoader().getResource("generator.yaml"); if (null == url || url.getPath().contains("jar")) { System.err.println("Can not find file named 'generator.yaml' under resources path, please make sure that you have defined that file."); System.exit(0); } else { Yaml yaml = new Yaml(new Constructor(Configuration.class)); InputStream inputStream = ConfigUtil.class.getClassLoader().getResourceAsStream("generator.yaml"); ConfigUtil.setConfiguration(yaml.load(inputStream)); } } catch (Exception e) { e.printStackTrace(); System.exit(0); } }
感谢回复,不过这样改的话,作者在这块写的替换驼峰的代码逻辑就会被删掉了,不知道是不是因为我们版本不一样,我是master分支的最新代码:
作者你好,不知道你最近还在不在更新,可能发现了一个bug IOUtils的toString方法中使用的是BufferedReader的readLine方法,此方法会丢失每行的换行符,会导致yaml解析时报错,具体情况如下: mapping values are not allowed here in 'reader', line 1, column 29: author: dumbcode projectName: test-1projectPath: D:\package ... ^
Disconnected from the target VM, address: '127.0.0.1:50170', transport: 'socket'
Process finished with exit code 0
我的修复方式是在句末重新append,这样会让此方法改为默认拼接换行