数据连接等相关的配置 xxx.properties
将xxx.properties放在项目的类路径下。如: config/xxx.properties
project.base.dir=项目的全路径jdbc.url=xxxjdbc.driver=com.mysql.cj.jdbc.Driverjdbc.username=xxxjdbc.password=xxxtable.name=xxxxdomain.object.name=xxxx
generatorConfig.xml 编写(最简形式)
java编写
/** * MyBatis Generator官网地址 * http://www.mybatis.org/generator/index.html * * @author Chris * @version V1.0 * @date 2019/05/13 */public class MybatisGenerator { public static void main(String[] args) { try { System.out.println("**************start generator***************"); Listwarnings = new ArrayList<>(); File configFile = new File(MybatisGenerator.class.getResource("/config/generatorConfig.xml").getFile()); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(true); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); warnings.forEach(System.out::println); System.out.println("*******************end generator*************"); } catch (Exception e) { e.printStackTrace(); } }}