欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mybatis-generator-maven-plugin

程序员文章站 2022-06-12 18:46:52
...

1、使用mybatis的maven的plugin,在pom.xml中添加

 

<plugin>
	<groupId>org.mybatis.generator</groupId>
	<artifactId>mybatis-generator-maven-plugin</artifactId>
	<version>1.3.2</version>
	<configuration>
		<configurationFile>generatorConfig.xml</configurationFile>
		<verbose>true</verbose>
		<overwrite>true</overwrite>
	</configuration>
	<executions>
		<execution>
			<id>Generate MyBatis Artifacts</id>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<dependencies>
		<dependency>
			<groupId>org.mybatis.generator</groupId>
			<artifactId>mybatis-generator-core</artifactId>
			<version>1.3.2</version>
		</dependency>
	</dependencies>
</plugin>

   

    src/main/resources/generatorConfig.properties

#Mybatis Generator configuration
#project = EKSP
#classPath=E:/workplace/EKSP/WebContent/WEB-INF/lib/ojdbc14.jar
#jdbc_driver = oracle.jdbc.driver.OracleDriver
#jdbc_url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
#jdbc_user=INFOGUARDIAN
#jdbc_password=info_idap132

project=/home/hok/workspace/xx-prj/src/main/java
classPath=/home/hok/.m2/repository/mysql/mysql-connector-java/5.1.25/mysql-connector-java-5.1.25.jar
jdbc_driver=com.mysql.jdbc.Driver
jdbc_url=jdbc:mysql://10.10.17.252:3306/test?useUnicode=true&amp;characterEncoding=UTF-8
jdbc_user=root
jdbc_password=123456
jdbc_schema=test

 

2、使用命令行

java -jar /home/hok/.m2/repository/org/mybatis/generator/mybatis-generator-core/1.3.2/mybatis-generator-core-1.3.2.jar  -configfile generatorConfig.xml

 这时候generatorConfig.properties必须放到mybatis-generator-core-1.3.2.jar里