新建SpringBoot项目
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ishangu</groupId>
<artifactId>MySpringBoot_mapper_MyBatis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MySpringBoot_mapper_MyBatis</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<!--配置通用mapper,数据库驱动等信息-->
<configuration>
<configurationFile>${project.basedir}/src/main/resources/generatorConfiguration.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.1.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
目的:自动生成xml,dao,model相关文件
<?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>
<context id="mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
<property name="caseSensitive" value="true"/>
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql:///house" password="123456" userId="root"/>
<javaModelGenerator targetPackage="com.ishangu.model" targetProject="./src/main/java">
<property name="enableSubPackages" value="false"/>
<property name="constructorBased" value="true"/>
<property name="immutable" value="false"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="mappers" targetProject="./src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.ishangu.dao" targetProject="./src/main/java"/>
<table tableName="good" domainObjectName="Good">
<generatedKey column="id" sqlStatement="jdbc"/>
</table>
</context>
</generatorConfiguration>
目的:运行依赖,生辰文件
目的:项目运行需要的数据库链接配置
#server.port=8888
#����bootĬ��ʹ�õ���tomcat������Դ����,����������Ҫ�ƶ�����Դ������
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
# ��������Դ
spring.datasource.url=jdbc:mysql:///house
spring.datasource.password=123456
spring.datasource.username=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# ��ʾsql���
spring.jpa.show-sql=true
找到Oracle自带的ojdbc6.jar
命令行运行mvn install:install-file -Dfile=d:/ojdbc6.jar -Dpackaging=jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1.0、