springboot+mybatis+oracle整合
一. 前期准备
1. 开发环境
- JDK1.8
- 开发集成环境 Spring Tool Suite 简称STS,下载地址
- apache-maven-3.6.0
2. 相关配置
2.1 maven相关配置
2.1.1 仓库配置
打开apache-maven-3.6.0
–>conf
–>settings.xml
文件
主要配置两点:本地仓库;在线镜像地址(如果不修改,默认连接境外地址,下载速度较慢。经测试连接阿里云仓库速度较快)。配置如下。
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- 配置本地仓库地址,我是放在E盘底下,repository文件夹自己建-->
<localRepository>E:/program/repository</localRepository>
<mirrors>
<!-- 阿里镜像仓库配置-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
.......
2.1.2 STS工具中配置
- 打开STS( Spring Tool Suite)导航栏
Window
–>Preferences
–>Maven
–>Installations
如下图
图1
图2
配置完成后就STS就使用我们自己下载的 maven 如图1所示勾选的就是我们自己下载的maven - 接着配置maven的配置文件
settings.xml
。让开发工具STS知道maven的具体配置,主要是我们前面配置的本地仓库,在线镜像地址。这样开发工具知道去哪个镜像下载jar包,然后存储到本地的什么地方。如下图所示
最后点击Apply and Close
配置生效。
二. springboot+mybatis
1. 创建项目
打开STS file
–>new
–>spring starter project
直接Next
选择springboot的版本,因为我们是一个web服务所以勾选web–>web.并且勾选SQL–>mybatis。实质上就是在maven的pom.xml
中加入需要的依赖。最后点击finish
。
2. 编辑pom.xml
导入依赖
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>