引入的pom文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>dev-tools</artifactId> <groupId>com.ai.shanghai.material</groupId> <version>1.0.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>mybatis-generator</artifactId> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <jdbc.Driver>${project.basedir}/lib/ojdbc6-11.2.0.3.jar</jdbc.Driver> <jdbc.driverClass>oracle.jdbc.OracleDriver</jdbc.driverClass> <!--<jdbc.Driver>${project.basedir}/lib/mysql-connector-java-5.1.38.jar</jdbc.Driver>--> <!--<jdbc.driverClass>com.mysql.jdbc.Driver</jdbc.driverClass>--> </properties> <dependencies> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.3</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.5</version> <configuration> <!--<skip>false</skip> <!–跳过执行–>--> <overwrite>true</overwrite> <verbose>true</verbose> <configurationFile>${basedir}/src/main/resources/generatorConfig.sample.xml</configurationFile> <outputDirectory>${basedir}/src/main/java</outputDirectory> </configuration> <executions> <execution> <id>Generate MyBatis Artifacts</id> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
在resource中配置xml文件
x<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <properties resource="init.sample.properties"/> <classPathEntry location="${jdbc.Driver}" /> <context id="MySqlTables" targetRuntime="MyBatis3"> <!--<jdbcConnection driverClass="${jdbc.driverClass}"--> <!--connectionURL="jdbc:mysql://127.0.0.1:3306/shoppingcar?useUnicode=true"--> <!--userId="root"--> <!--password="root">--> <!--</jdbcConnection>--> <jdbcConnection driverClass="${jdbc.driverClass}" connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:BSSA10G3" userId="root" password="root"> </jdbcConnection> <javaModelGenerator targetPackage="${model.package}" targetProject="${model.target}"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <sqlMapGenerator targetPackage="${mapxml.package}" targetProject="${mapxml.target}"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <javaClientGenerator type="XMLMAPPER" targetPackage="${mapper.package}" targetProject="${mapper.target}"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!--需要生成的表请按以下配置(tableName 是实际的表名 domainObjectName 映射成的java对象名) --> <table tableName="TF_F_GOVERENTER_REQUEST_LOGS" domainObjectName="TFFGoverenterRequestLogs"></table> </context> </generatorConfiguration>
配置文件生成目录
#model.package = com.ai.mine.dao.model #model.target = D:\\IdeaProjects\\dev_tools\\model # #mapxml.package = sqlmapper.system #mapxml.target = D:\\IdeaProjects\\dev_tools\\mapperX # #mapper.package = com.ai.mine.dao.mapper #mapper.target = D:\\IdeaProjects\\dev_tools\\mapperJ model.package = com.ai.mine.system.dao.model model.target = D:\\git\\dev-tools\\model mapxml.package = sqlmapper mapxml.target = D:\\git\\dev-tools\\mapperX mapper.package = com.ai.mine.dao.mapper mapper.target = D:\\git\\dev-tools\\mapperJ
打包maven启动 install执行jar