Mybatis Generator配置文件中,generatorConfiguration元素有一个子元素properties,可以用来指定一个java属性文件,从而配置文件内可以通过${property}来引用属性对应的值。可以将一些通用的属性放到共享的属性文件中减少一些冗余。
properties子元素有两个互斥的属性resource和url,resource用来指定类路径下的属性文件,url用来指定文件系统路径指示的属性文件。
resource:配置资源加载地址,使用resource,MBG从classpath开始找,比如com/myproject/generatorConfig.properties
url:配置资源加载地质,使用URL的方式,比如file:///C:/myfolder/generatorConfig.properties.1
2
3<!--如下两者互斥,只能存在其一-->
<properties resource="generator.properties"></properties>
<properties url="file:///C:\Users\dell\Desktop\MES_Device\src\main\resources\mybatis-generator\generator.properties"></properties>
注意:properties元素最好放在第一个,否则可能会出一下莫名其妙的错误。最好使用url配置绝对路径,直接通过命令行使用resource的时候classpath不好指定。
在generatorConfiguration中最多只能有一个properties。