TOP

SpringBoot整合Mybatis(CRUD的实现)(一)
2019-09-06 00:26:39 】 浏览:69
Tags:SpringBoot 整合 Mybatis CRUD 实现

准备工具:IDEA   jdk1.8  Navicat for MySQL  Postman

 

一、新建Project

选择依赖:mybatis  Web  Mysql  JDBC

项目结构

pom依赖:

 1 xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 4     <modelVersion>4.0.0modelVersion>
 5     <parent>
 6         <groupId>org.springframework.bootgroupId>
 7         <artifactId>spring-boot-starter-parentartifactId>
 8         <version>2.1.7.RELEASEversion>
 9         <relativePath/> 
10     parent>
11     <groupId>com.beilingroupId>
12     <artifactId>SpringBoot-MybatisartifactId>
13     <version>0.0.1-SNAPSHOTversion>
14     <name>SpringBoot-Mybatisname>
15     <description>Demo project for Spring Bootdescription>
16 
17     <properties>
18         <java.version>1.8java.version>
19     properties>
20     <dependencies>
21         <dependency>
22             <groupId>org.springframework.bootgroupId>
23             <artifactId>spring-boot-starter-jdbcartifactId>
24         dependency>
25         <dependency>
26             <groupId>org.springframework.bootgroupId>
27             <artifactId>spring-boot-starter-webartifactId>
28         dependency>
29 
30         
31         <dependency>
32             <groupId>org.mybatis.spring.bootgroupId>
33             <artifactId>mybatis-spring-boot-starterartifactId>
34             <version>2.1.0version>
35         dependency>
36 
37         
38         <dependency>
39             <groupId>mysqlgroupId>
40             <artifactId>mysql-connector-javaartifactId>
41             <version>5.1.47version>
42         dependency>
43 
44         <dependency>
45             <groupId>org.springframework.bootgroupId>
46             <artifactId>spring-boot-starter-testartifactId>
47             <scope>testscope>
48         dependency>
49     dependencies>
50 
51     <build>
52         <plugins>
53             <plugin>
54                 <groupId>org.springframework.bootgroupId>
55                 <artifactId>spring-boot-maven-pluginartifactId>
56             plugin>
57         plugins>
58     build>
59 
60 project>
pom.xml

二、创建user表

 

 

 、项目配置

1 .在com.beilin下创建controller包、mapper包,entity包;在resources文件夹下创建mapping文件夹(用来存放mapper映射的xml文件)

 

 

 2 .添加properties配置文件:application.properties

 1 #配置mybatis
 2 
 3 #配置xml映射路径
 4 mybatis.mapper-locations=classpath:mapping/*.xml
 5 #配置实体类别名
 6 mybatis.type-aliases-package=com.beilin.entity
 7 #开启驼峰命名法
 8 mybatis.configuration.map-underscore-to-camel-case=true
 9 
10 #配置Mysql连接
11 spring.datasource.url=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
12 s  
		
SpringBoot整合Mybatis(CRUD的实现)(一) https://www.cppentry.com/bencandy.php?fid=102&id=250200

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇什么是SEO?SEO能做什么! 下一篇IIS 程序池优化配置方案

kafka-
kafka   Partit
解决android studio
Kafka史上最详细原理
Error while fetchin
【Kafka】安装与快速
    &
flume读取日志数据写
Authentication plug
Flume 自定义source
flume   三大核
ICC副本>>>
愚公移山  
Hbase架构   Hb
5 hbase-shell + &
Hbase   MapRed
MetaException(messa
Exception in thread
HIVE metastore Dupl
-->