直接拿https://mybatis.org/generator/running/runningWithJava.html
中的测试文件来运行,在主方法中运行后没有任何错误。
//没生成时的错误信息存放集合
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File("D:\\中公学习\\三阶段\\day04\\mybatis_03_back\\src\\main\\resources\\generator.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
然后,我配置了日志文件,显示的日志信息一切正常:
但是仍然没有生成对应的文件。
所以我打印了对应的生成对应的信息的集合
可以看出,是我的路径错误,在此工程下,有很多的模块,所以需要加上模块的路径:
然后就可以生成成功了: