resorues所需xml文件(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:\IDEA2021Demo0\apache-maven-3.6.3\mvn_resp\mysql\mysql-connector-java\5.1.47\mysql-connector-java-5.1.47.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库连接参数 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" userId="root" password="2770085055"
connectionURL="jdbc:mysql://localhost:3306/ssm?useSSL=false&nullNamePatternMatchesAll=true">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 实体类的包名和存放路径 -->
<javaModelGenerator targetPackage="com.santi.pojo" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件*.xml的位置-->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.santi.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- tableName:数据库中的表名或视图名;domainObjectName:生成的实体类的类名-->
<table tableName="emp" domainObjectName="Emp"
enableCountByExample="true"
enableUpdateByExample="true"
enableDeleteByExample="true"
enableSelectByExample="true"
selectByExampleQueryId="true"/>
</context>
<!-- <classPathEntry location="E:\repository\mysql\mysql-connector-java\8.0.26\mysql-connector-java-8.0.26.jar" />-->
<!-- <context id="DB2Tables" targetRuntime="MyBatis3">-->
<!-- <!–数据库链接URL,用户名、密码 –>-->
<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver"-->
<!-- connectionURL="jdbc:mysql://localhost:3306/book?useSSL=false&nullNamePatternMatchesAll=true"-->
<!-- userId="root"-->
<!-- password="xxx">-->
<!-- <!–设置可以获取tables remarks信息–>-->
<!-- <property name="useInformationSchema" value="true"/>-->
<!-- <!–设置可以获取remarks信息–>-->
<!-- <property name="remarks" value="true"/>-->
<!-- </jdbcConnection>-->
<!-- <!– 生成模型的包名和位置 –>-->
<!-- <javaModelGenerator targetPackage="com.santi.entity"-->
<!-- targetProject="src/main/java">-->
<!-- <property name="enableSubPackages" value="true" />-->
<!-- <property name="trimStrings" value="true" />-->
<!-- </javaModelGenerator>-->
<!-- <!– 生成映射文件的包名和位置 –>-->
<!-- <sqlMapGenerator targetPackage="com.santi.mapper"-->
<!-- targetProject="src/main/java" >-->
<!-- <property name="enableSubPackages" value="true" />-->
<!-- </sqlMapGenerator>-->
<!-- <!– 生成DAO的包名和位置 –>-->
<!-- <javaClientGenerator type="XMLMAPPER"-->
<!-- targetPackage="com.santi.mapper" targetProject="src/main/java">-->
<!-- <property name="enableSubPackages" value="true" />-->
<!-- </javaClientGenerator>-->
<!-- <table catalog="book" tableName="t_book" domainObjectName="Book">-->
<!-- <property name="ignoreQualifiersAtRuntime" value="true" />-->
<!-- <generatedKey column="id" sqlStatement="mysql" identity="true" />-->
<!-- </table>-->
<!-- </context>-->
</generatorConfiguration>
pom.xml文件的jar:
<?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.santi</groupId>
<artifactId>Spring-Mybatis</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<!--mybatis-generator的jar-->
<mybatis-generator-maven-plugin.version>1.3.2</mybatis-generator-maven-plugin.version>
<mybatis-generator-core.version>1.3.2</mybatis-generator-core.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${mybatis-generator-core.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.ibatis/ibatis-core -->
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-core</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build>
<finalName>Spring-Mybatis</finalName>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>${mybatis-generator-maven-plugin.version}</version>
<configuration>
<!-- mybatis-generator配置文件路径 -->
<configurationFile>src/main/resources/generatorConfig.xml
</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
</build>
</project>
最后添加配置:
在Editor Configurations里添加Maven ,第一个选项中 第一个为你的模块,第二个填:
mybatis-generator:generate 然后打开Maven
?双击spring-mybatis,出现
就成功了?
|