first commit

This commit is contained in:
zhangyang 2024-06-14 16:58:54 +08:00
commit d5f4c7eab9
3 changed files with 120 additions and 0 deletions

36
pom.xml Normal file
View File

@ -0,0 +1,36 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.longhuan</groupId>
<artifactId>mybatis-generator</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,42 @@
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- MyBatis3Simple风格 -->
<context id="simple" targetRuntime="MyBatis3Simple">
<property name="javaFileEncoding" value="UTF-8"/>
<!--生成mapper.xml时覆盖原文件-->
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>
<commentGenerator>
<!-- 是否去除自动生成的注释 true false:否。 自动生成注释太啰嗦可以编码扩展CommentGenerator -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!-- 数据库连接 -->
<jdbcConnection driverClass="org.postgresql.Driver"
connectionURL="jdbc:postgresql://192.168.9.238:5432/longhuan?currentSchema=user"
userId="longhuan_user" password="user123">
<!-- 设置为true就只读取db_book下的表, 否则会优先读取到mysql的user表 -->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!-- 生成PO的包名和位置 -->
<javaModelGenerator targetPackage="com.longhuan.dao.pojo" targetProject="src/main/java"/>
<!-- 生成XML映射文件的包名和位置 -->
<sqlMapGenerator targetPackage="com.longhuan.dao.mapper" targetProject="src/main/resources"/>
<!-- 生成Mapper接口的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.longhuan.dao.mapper" targetProject="src/main/java"/>
<!-- 要生成对应表配置 -->
<table tableName="user" domainObjectName="User" >
<!-- 自增主键列 -->
<generatedKey column="id" sqlStatement="MYSQL" identity="true"/>
<!-- tinyint映射为Integer -->
<columnOverride column="role" javaType="Integer" jdbcType="TINYINT"/>
</table>
</context>
</generatorConfiguration>

View File

@ -0,0 +1,42 @@
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- MyBatis3Simple风格 -->
<context id="simple" targetRuntime="MyBatis3Simple">
<property name="javaFileEncoding" value="UTF-8"/>
<!--生成mapper.xml时覆盖原文件-->
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>
<commentGenerator>
<!-- 是否去除自动生成的注释 true false:否。 自动生成注释太啰嗦可以编码扩展CommentGenerator -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!-- 数据库连接 -->
<jdbcConnection driverClass="org.postgresql.Driver"
connectionURL="jdbc:postgresql://192.168.9.238:5432/longhuan?currentSchema=user"
userId="postgres" password="123456">
<!-- 设置为true就只读取db_book下的表, 否则会优先读取到mysql的user表 -->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!-- 生成PO的包名和位置 -->
<javaModelGenerator targetPackage="com.longhuan.dao.pojo" targetProject="src/main/java"/>
<!-- 生成XML映射文件的包名和位置 -->
<sqlMapGenerator targetPackage="com.longhuan.dao.mapper" targetProject="src/main/resources"/>
<!-- 生成Mapper接口的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.longhuan.dao.mapper" targetProject="src/main/java"/>
<!-- 要生成对应表配置 -->
<table tableName="user" domainObjectName="User" >
<!-- 自增主键列 -->
<generatedKey column="id" sqlStatement="MYSQL" identity="true"/>
<!-- tinyint映射为Integer -->
<columnOverride column="role" javaType="Integer" jdbcType="TINYINT"/>
</table>
</context>
</generatorConfiguration>