逆向工程

一、逆向工程(srpingboot)

resources中generatorConfig.xml

<?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>
	
	<!-- 指定数据库驱动jar包 -->
	<classPathEntry location="D:developmaven-repositorymysqlmysql-connector-java8.0.17mysql-connector-java-8.0.17.jar"/>
	
	<context id="context1">
		
		<!-- 配置注释生成 -->
		<commentGenerator>
			<!-- 是否去除自动生成的注释 true:是 : false:否 -->
			<property name="suppressAllComments" value="false" />
		</commentGenerator>
		
		<!-- 配置连接数据库 -->
		<jdbcConnection connectionURL="jdbc:mysql://127.0.0.1:3306/shop?serverTimezone=UTC" 
						driverClass="com.mysql.cj.jdbc.Driver"
						password="123456" 
						userId="root"/>
		<!-- 配置实体生成 -->	
		<javaModelGenerator targetPackage="cn.kooun.pojo.table"
							targetProject="web"/>
		
		<!-- 配置sql映射文件生成 -->	
		<sqlMapGenerator targetPackage="cn.kooun.mapper" 
						 targetProject="web"/>
		
		<!-- 配置数据访问接口类生成  -->
		<javaClientGenerator targetPackage="cn.kooun.mapper"
							 targetProject="web" type="XMLMAPPER" />
		
		<!-- 配置表相关信息 -->	
		<table schema="shop" tableName="u_user"
				domainObjectName="User"
				enableCountByExample="false" 
				enableDeleteByExample="false"
				enableSelectByExample="false" 
				enableUpdateByExample="false">
			<!-- 列映射成属性配置 -->
			<columnOverride column="content" property="content" />
		</table>
	</context>
	
</generatorConfiguration>

二、逆向工程在eclipse中的运行

2.1 将逆向工程插件(jar包)放置在eclipse安装目录下相同的包下,重启eclipse

将逆向工程插件放在eclipse的相同目录下,重启eclipse.jpg

2.2 eclipse中运行

逆向工程的运行.jpg

以上运行成功,会自动生成对应表的pojo类和dao层的mapper类和mapper.xml

eclipse中安装springboot插件

eclipse安装springboot插件.png

原文地址:https://www.cnblogs.com/nadou/p/13999222.html