个人开源项目

更多干货

SpringBoot系列目录

正题

本项目使用的环境:

  • 开发工具:Intellij IDEA 2017.1.3
  • springboot: 1.5.6
  • jdk:1.8.0_161
  • maven:3.3.9

额外功能

  • PageHelper 分页插件
  • mybatis generator 自动生成代码插件

步骤:
1.创建一个springboot项目:

2.创建项目的文件结构以及jdk的版本

3.选择项目所需要的依赖


然后点击finish

5.看一下文件的结构:

6.查看一下pom.xml:

  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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>com.winter</groupId>
  6. <artifactId>springboot-mybatis-demo</artifactId>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <packaging>jar</packaging>
  9. <name>springboot-mybatis-demo</name>
  10. <description>Demo project for Spring Boot</description>
  11. <parent>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactId>spring-boot-starter-parent</artifactId>
  14. <version>1.5.6.RELEASE</version>
  15. <relativePath/> <!-- lookup parent from repository -->
  16. </parent>
  17. <properties>
  18. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  19. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  20. <java.version>1.7</java.version>
  21. </properties>
  22. <dependencies>
  23. <dependency>
  24. <groupId>org.mybatis.spring.boot</groupId>
  25. <artifactId>mybatis-spring-boot-starter</artifactId>
  26. <version>1.3.0</version>
  27. </dependency>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework.boot</groupId>
  34. <artifactId>spring-boot-starter-web</artifactId>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-starter-test</artifactId>
  39. <scope>test</scope>
  40. </dependency>
  41. <dependency>
  42. <groupId>mysql</groupId>
  43. <artifactId>mysql-connector-java</artifactId>
  44. <version>5.1.35</version>
  45. </dependency>
  46. <dependency>
  47. <groupId>com.fasterxml.jackson.core</groupId>
  48. <artifactId>jackson-core</artifactId>
  49. </dependency>
  50. <dependency>
  51. <groupId>com.fasterxml.jackson.core</groupId>
  52. <artifactId>jackson-databind</artifactId>
  53. </dependency>
  54. <dependency>
  55. <groupId>com.fasterxml.jackson.datatype</groupId>
  56. <artifactId>jackson-datatype-joda</artifactId>
  57. </dependency>
  58. <dependency>
  59. <groupId>com.fasterxml.jackson.module</groupId>
  60. <artifactId>jackson-module-parameter-names</artifactId>
  61. </dependency>
  62. <!-- 分页插件 -->
  63. <dependency>
  64. <groupId>com.github.pagehelper</groupId>
  65. <artifactId>pagehelper-spring-boot-starter</artifactId>
  66. <version>1.1.2</version>
  67. </dependency>
  68. <!-- alibaba的druid数据库连接池 -->
  69. <dependency>
  70. <groupId>com.alibaba</groupId>
  71. <artifactId>druid-spring-boot-starter</artifactId>
  72. <version>1.1.0</version>
  73. </dependency>
  74. </dependencies>
  75. <build>
  76. <plugins>
  77. <plugin>
  78. <groupId>org.springframework.boot</groupId>
  79. <artifactId>spring-boot-maven-plugin</artifactId>
  80. </plugin>
  81. <!-- mybatis generator 自动生成代码插件 -->
  82. <plugin>
  83. <groupId>org.mybatis.generator</groupId>
  84. <artifactId>mybatis-generator-maven-plugin</artifactId>
  85. <version>1.3.2</version>
  86. <configuration>
  87. <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile>
  88. <overwrite>true</overwrite>
  89. <verbose>true</verbose>
  90. </configuration>
  91. </plugin>
  92. </plugins>
  93. </build>
  94. </project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106

7.项目不使用application.properties文件 而使用更加简洁的application.yml文件:
将原有的resource文件夹下的application.properties文件删除,创建一个新的application.yml配置文件,
文件的内容如下:


  1. server:
  2. port: 8080
  3. spring:
  4. datasource:
  5. name: test
  6. url: jdbc:mysql://127.0.0.1:3306/depot
  7. username: root
  8. password: root
  9. # 使用druid数据源
  10. type: com.alibaba.druid.pool.DruidDataSource
  11. driver-class-name: com.mysql.jdbc.Driver
  12. filters: stat
  13. maxActive: 20
  14. initialSize: 1
  15. maxWait: 60000
  16. minIdle: 1
  17. timeBetweenEvictionRunsMillis: 60000
  18. minEvictableIdleTimeMillis: 300000
  19. validationQuery: select 'x'
  20. testWhileIdle: true
  21. testOnBorrow: false
  22. testOnReturn: false
  23. poolPreparedStatements: true
  24. maxOpenPreparedStatements: 20
  25. ## 该配置节点为独立的节点,有很多同学容易将这个配置放在spring的节点下,导致配置无法被识别
  26. mybatis:
  27. mapper-locations: classpath:mapping/*.xml #注意:一定要对应mapper映射xml文件的所在路径
  28. type-aliases-package: com.winter.model # 注意:对应实体类的路径
  29. #pagehelper分页插件
  30. pagehelper:
  31. helperDialect: mysql
  32. reasonable: true
  33. supportMethodsArguments: true
  34. params: count=countSql
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

8.创建数据库:

  1. CREATE DATABASE mytest;
  2. CREATE TABLE t_user(
  3. user_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  4. user_name VARCHAR(255) NOT NULL ,
  5. password VARCHAR(255) NOT NULL ,
  6. phone VARCHAR(255) NOT NULL
  7. ) ENGINE=INNODB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

9.使用mybatis generator 自动生成代码:

  • 配置pom.xml中generator 插件所对应的配置文件 ${basedir}/src/main/resources/generator/generatorConfig.xml
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE generatorConfiguration
  3. PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  4. "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
  5. <generatorConfiguration>
  6. <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
  7. <classPathEntry location="E:\developer\mybatis-generator-core-1.3.2\lib\mysql-connector-java-5.1.25-bin.jar"/>
  8. <context id="DB2Tables" targetRuntime="MyBatis3">
  9. <commentGenerator>
  10. <property name="suppressDate" value="true"/>
  11. <!-- 是否去除自动生成的注释 true:是 : false:否 -->
  12. <property name="suppressAllComments" value="true"/>
  13. </commentGenerator>
  14. <!--数据库链接URL,用户名、密码 -->
  15. <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1/mytest" userId="root" password="root">
  16. </jdbcConnection>
  17. <javaTypeResolver>
  18. <property name="forceBigDecimals" value="false"/>
  19. </javaTypeResolver>
  20. <!-- 生成模型的包名和位置-->
  21. <javaModelGenerator targetPackage="com.winter.model" targetProject="src/main/java">
  22. <property name="enableSubPackages" value="true"/>
  23. <property name="trimStrings" value="true"/>
  24. </javaModelGenerator>
  25. <!-- 生成映射文件的包名和位置-->
  26. <sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources">
  27. <property name="enableSubPackages" value="true"/>
  28. </sqlMapGenerator>
  29. <!-- 生成DAO的包名和位置-->
  30. <javaClientGenerator type="XMLMAPPER" targetPackage="com.winter.mapper" targetProject="src/main/java">
  31. <property name="enableSubPackages" value="true"/>
  32. </javaClientGenerator>
  33. <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
  34. <table tableName="t_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
  35. </context>
  36. </generatorConfiguration>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 点击run-Edit Configurations

  • 添加配置

  • 运行
    注意!!!同一张表一定不要运行多次,因为mapper的映射文件中会生成多次的代码,导致报错,切记

    最后生成的文件以及结构:

10. 生成的文件

UserMapper.java

  1. package com.winter.mapper;
  2. import com.winter.model.User;
  3. public interface UserMapper {
  4. int deleteByPrimaryKey(Integer userId);
  5. int insert(User record);
  6. int insertSelective(User record);
  7. User selectByPrimaryKey(Integer userId);
  8. int updateByPrimaryKeySelective(User record);
  9. int updateByPrimaryKey(User record);
  10. //这个方式我自己加的
  11. List<User> selectAllUser();
  12. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

User.java

  1. package com.winter.model;
  2. public class User {
  3. private Integer userId;
  4. private String userName;
  5. private String password;
  6. private String phone;
  7. public Integer getUserId() {
  8. return userId;
  9. }
  10. public void setUserId(Integer userId) {
  11. this.userId = userId;
  12. }
  13. public String getUserName() {
  14. return userName;
  15. }
  16. public void setUserName(String userName) {
  17. this.userName = userName == null ? null : userName.trim();
  18. }
  19. public String getPassword() {
  20. return password;
  21. }
  22. public void setPassword(String password) {
  23. this.password = password == null ? null : password.trim();
  24. }
  25. public String getPhone() {
  26. return phone;
  27. }
  28. public void setPhone(String phone) {
  29. this.phone = phone == null ? null : phone.trim();
  30. }
  31. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

对于sql语句这种黄色的背景,真心是看不下去了(解决方案):

UserMapper.xml


  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.winter.mapper.UserMapper" >
  4. <resultMap id="BaseResultMap" type="com.winter.model.User" >
  5. <id column="user_id" property="userId" jdbcType="INTEGER" />
  6. <result column="user_name" property="userName" jdbcType="VARCHAR" />
  7. <result column="password" property="password" jdbcType="VARCHAR" />
  8. <result column="phone" property="phone" jdbcType="VARCHAR" />
  9. </resultMap>
  10. <sql id="Base_Column_List" >
  11. user_id, user_name, password, phone
  12. </sql>
  13. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  14. select
  15. <include refid="Base_Column_List" />
  16. from t_user
  17. where user_id = #{userId,jdbcType=INTEGER}
  18. </select>
  19. <!-- 这个方法是我自己加的 -->
  20. <select id="selectAllUser" resultMap="BaseResultMap">
  21. select
  22. <include refid="Base_Column_List" />
  23. from t_user
  24. </select>
  25. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  26. delete from t_user
  27. where user_id = #{userId,jdbcType=INTEGER}
  28. </delete>
  29. <insert id="insert" parameterType="com.winter.model.User" >
  30. insert into t_user (user_id, user_name, password,
  31. phone)
  32. values (#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
  33. #{phone,jdbcType=VARCHAR})
  34. </insert>
  35. <insert id="insertSelective" parameterType="com.winter.model.User" >
  36. insert into t_user
  37. <trim prefix="(" suffix=")" suffixOverrides="," >
  38. <if test="userId != null" >
  39. user_id,
  40. </if>
  41. <if test="userName != null" >
  42. user_name,
  43. </if>
  44. <if test="password != null" >
  45. password,
  46. </if>
  47. <if test="phone != null" >
  48. phone,
  49. </if>
  50. </trim>
  51. <trim prefix="values (" suffix=")" suffixOverrides="," >
  52. <if test="userId != null" >
  53. #{userId,jdbcType=INTEGER},
  54. </if>
  55. <if test="userName != null" >
  56. #{userName,jdbcType=VARCHAR},
  57. </if>
  58. <if test="password != null" >
  59. #{password,jdbcType=VARCHAR},
  60. </if>
  61. <if test="phone != null" >
  62. #{phone,jdbcType=VARCHAR},
  63. </if>
  64. </trim>
  65. </insert>
  66. <update id="updateByPrimaryKeySelective" parameterType="com.winter.model.User" >
  67. update t_user
  68. <set >
  69. <if test="userName != null" >
  70. user_name = #{userName,jdbcType=VARCHAR},
  71. </if>
  72. <if test="password != null" >
  73. password = #{password,jdbcType=VARCHAR},
  74. </if>
  75. <if test="phone != null" >
  76. phone = #{phone,jdbcType=VARCHAR},
  77. </if>
  78. </set>
  79. where user_id = #{userId,jdbcType=INTEGER}
  80. </update>
  81. <update id="updateByPrimaryKey" parameterType="com.winter.model.User" >
  82. update t_user
  83. set user_name = #{userName,jdbcType=VARCHAR},
  84. password = #{password,jdbcType=VARCHAR},
  85. phone = #{phone,jdbcType=VARCHAR}
  86. where user_id = #{userId,jdbcType=INTEGER}
  87. </update>
  88. </mapper>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89

11.打开类SpringbootMybatisDemoApplication.java,这个是springboot的启动类。我们需要添加点东西:

  1. package com.winter;
  2. import org.mybatis.spring.annotation.MapperScan;
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. @SpringBootApplication
  6. @MapperScan("com.winter.mapper")//将项目中对应的mapper类的路径加进来就可以了
  7. public class SpringbootMybatisDemoApplication {
  8. public static void main(String[] args) {
  9. SpringApplication.run(SpringbootMybatisDemoApplication.class, args);
  10. }
  11. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

注意:@MapperScan("com.winter.mapper")这个注解非常的关键,这个对应了项目中mapper(dao)所对应的包路径,很多同学就是这里忘了加导致异常的

12.到这里所有的搭建工作都完成了,接下来就是测试的工作,没使用junit4进行测试:
首先看一下完成之后的文件的结构:

现在controller,service层的代码都写好:

UserController.java

  1. package com.winter.Controller;
  2. import com.winter.model.User;
  3. import com.winter.service.UserService;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.ResponseBody;
  9. /**
  10. * Created by Administrator on 2017/8/16.
  11. */
  12. @Controller
  13. @RequestMapping(value = "/user")
  14. public class UserController {
  15. @Autowired
  16. private UserService userService;
  17. @ResponseBody
  18. @RequestMapping(value = "/add", produces = {"application/json;charset=UTF-8"})
  19. public int addUser(User user){
  20. return userService.addUser(user);
  21. }
  22. @ResponseBody
  23. @RequestMapping(value = "/all/{pageNum}/{pageSize}", produces = {"application/json;charset=UTF-8"})
  24. public Object findAllUser(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize){
  25. return userService.findAllUser(pageNum,pageSize);
  26. }
  27. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

UserService.java

  1. package com.winter.service;
  2. import com.winter.model.User;
  3. import java.util.List;
  4. /**
  5. * Created by Administrator on 2017/8/16.
  6. */
  7. public interface UserService {
  8. int addUser(User user);
  9. List<User> findAllUser(int pageNum, int pageSize);
  10. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

UserServiceImpl.java

  1. package com.winter.service.impl;
  2. import com.github.pagehelper.PageHelper;
  3. import com.winter.mapper.UserMapper;
  4. import com.winter.model.User;
  5. import com.winter.service.UserService;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import java.util.List;
  9. /**
  10. * Created by Administrator on 2017/8/16.
  11. */
  12. @Service(value = "userService")
  13. public class UserServiceImpl implements UserService {
  14. @Autowired
  15. private UserMapper userMapper;//这里会报错,但是并不会影响
  16. @Override
  17. public int addUser(User user) {
  18. return userMapper.insertSelective(user);
  19. }
  20. /*
  21. * 这个方法中用到了我们开头配置依赖的分页插件pagehelper
  22. * 很简单,只需要在service层传入参数,然后将参数传递给一个插件的一个静态方法即可;
  23. * pageNum 开始页数
  24. * pageSize 每页显示的数据条数
  25. * */
  26. @Override
  27. public List<User> findAllUser(int pageNum, int pageSize) {
  28. //将参数传给这个方法就可以实现物理分页了,非常简单。
  29. PageHelper.startPage(pageNum, pageSize);
  30. return userMapper.selectAllUser();
  31. }
  32. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

如果强迫症看不下去那个报错:(解决方法)

测试我使用了idea一个很用心的功能。
可以发http请求的插件

点击左侧的运行按钮就可以发送请求了;
如果返回值正确 说明你已经搭建成功了!!

如果出现mapper注入不了的情况,请检查版本,当前博客的搭建方法只适合1.5.*版本的,如果你的版本是2.0以上的版本,请参照我的另一篇博客的mybatis的配置:springboot2.0整合mybatis

如果大家想使用事务控制的话,请参照Spring boot Mybatis 整合(注解版) ,这个里面就有关于事务控制的使用

源码地址:https://github.com/WinterChenS/springboot-mybatis-demo

springboot技术交流群:681513531

Spring boot Mybatis 整合(完整版)的更多相关文章

  1. Spring boot Mybatis 整合

    PS: 参考博客 PS: spring boot配置mybatis和事务管理 PS: Spring boot Mybatis 整合(完整版)   这篇博客里用到了怎样 生成 mybatis 插件来写程 ...

  2. Spring boot Mybatis 整合(注解版)

    之前写过一篇关于springboot 与 mybatis整合的博文,使用了一段时间spring-data-jpa,发现那种方式真的是太爽了,mybatis的xml的映射配置总觉得有点麻烦.接口定义和映 ...

  3. Spring boot Mybatis整合构建Rest服务(超细版)

     Springboot+ Mybatis+MySql整合构建Rest服务(涵盖增.删.改.查) 1.概要 1.1 为什么要使用Spring  boot? 1.1.1 简单方便.配置少.整合了大多数框架 ...

  4. Spring Boot Mybatis整合

    Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置. 特 ...

  5. spring boot +mybatis 整合 连接数据库测试(从0到1)

    spring boot 整合mybatis 1.打开idea创建一个项目 2.在弹出的窗口中选择spring initializr(初始化项目),点击next 3.接下来填写group 与artifa ...

  6. spring boot mybatis 整合教程

    本项目使用的环境: 开发工具:Intellij IDEA 2017.1.3 springboot: 1.5.6 jdk:1.8.0_161 maven:3.3.9 额外功能 PageHelper 分页 ...

  7. SpringMVC+Spring+MyBatis整合完整版Web实例(附数据)

    最近段时间正在学习Spring MVC和MyBatis的一些知识.自己也在网络上面找了一些例子来练习.但是都不是很完整.所以,今天,自己也抽空写了个完成的关于Spring MVC + Spring + ...

  8. spring boot+mybatis+quartz项目的搭建完整版

    1. 利用spring boot提供的工具(http://start.spring.io/)自动生成一个标准的spring boot项目架构 2. 因为这里我们是搭建spring boot+mybat ...

  9. Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结

    Spring Boot + MyBatis + Druid + Redis + Thymeleaf 整合小结 这两天闲着没事想利用**Spring Boot**加上阿里的开源数据连接池**Druid* ...

随机推荐

  1. [Python设计模式] 第22章 手机型号&软件版本——桥接模式

    github地址:https://github.com/cheesezh/python_design_patterns 紧耦合程序演化 题目1 编程模拟以下情景,有一个N品牌手机,在上边玩一个小游戏. ...

  2. DockerSwarm获取Token与常用命令

    一.Token相关 Join tokens是允许一个节点加入集群的密钥.有两种可用的不同的join tokens,一个是用作worker角色,另一个是用作manager角色.在执行swarm join ...

  3. Springboot 生成验证码

    技术:springboot+kaptcha+session   概述 场景介绍 验证码,用于web网站.用户点击验证码图片后,生成验证码.提交后,用户输入验证码和Session验证码,进行校验. 详细 ...

  4. Visual Studio 2015 update 3各版本下载地址

    微软在06月27日发布了Visual Studio 2015 Update 3 .在MSDN中微软也提供下载,而且MSDN的Visual Studio 2015 Update 3与官方免费下载的文件是 ...

  5. vue: 代码小记

    1.事件派发:子控件->父控件 <!DOCTYPE html> <html> <head> <meta charset="UTF-8" ...

  6. Navicat Win 和 Mac 视图类快捷键对比

    Navicat 查询是根据用户需求从数据库提取可读格式的数据,Navicat 提供两个强大的工具与 SQL 查询工作:查询创建工具和查询编辑器,查询创建工具可视觉化地创建查询,查询编辑器可直接编辑查询 ...

  7. Mongodb系列- spring-data-mongodb使用MongoTemplate实现分页查询

    在用spring-data-mongodb框架开发的过程中,需要实现分页查询,就百度了下,没找到满意的又google了下,找到了思路. 在spring-data-mongodb 官方文档中,建议你使用 ...

  8. SQL Server 性能优化实战系列(二)

    SQL Server datetime数据类型设计.优化误区 一.场景 在SQL Server 2005中,有一个表TestDatetime,其中Dates这个字段的数据类型是datetime,如果你 ...

  9. 【C++】C++中assert和ENDEGU预处理语句

    assert 断言语句是C++中的一种预处理宏语句,它能在程序运行时根据否定条件中断程序. C++中的assert()函数可以实现断言功能,在使用assert函数之前应该先引入<cassert& ...

  10. TLB的作用及工作原理

    TLB的作用及工作过程 以下内容摘自<步步惊芯——软核处理器内部设计分析>一书 页表一般都很大,并且存放在内存中,所以处理器引入MMU后,读取指令.数据需要访问两次内存:首先通过查询页表得 ...