本篇文章为你整理了MyBatis Generator Core – Running MyBatis Generator With Java()的详细内容,包含有 MyBatis Generator Core – Running MyBatis Generator With Java,希望能帮助你了解 MyBatis Generator Core – Running MyBatis Generator With Java。
MyBatis Generator (MBG) may be invoked directly from Java. For configuration,
you may use either an XML configuration file, or configure MBG completely with
Java.
Running MBG from Java with an XML Configuration File
The following code sample shows how to call MBG from Java with an XML based configuration.
It does not
show exception handling, but that should be obvious from the compiler
errors :)
File configFile = new File( generatorConfig.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);
Configuration file properties may be passed to the parser as a parameter on
the ConfigurationParser constructor. If not passed explicitly, the JVM
system properties will be searched for the value of configuration file
properties. For example, the property
generated.source.dir can be
accessed in the configuration file with the escape sequence
${generated.source.dir}
If a property is specified in the configuration file and is not resolved,
then the escaped property string will be passed as is into the generated code.
Running MBG from Java with a Java Based Configuration
The following code sample shows how to call MBG from Java with a Java based configuration.
It does
not show exception handling, but that should be obvious from the compiler
errors :)
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
以上就是MyBatis Generator Core – Running MyBatis Generator With Java()的详细内容,想要了解更多 MyBatis Generator Core – Running MyBatis Generator With Java的内容,请持续关注盛行IT软件开发工作室。
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。