zoukankan      html  css  js  c++  java
  • spring boot整合使用mybatis

    1)pom文件引入

    <parent>

                <groupId>org.springframework.boot</groupId>

                <artifactId>spring-boot-starter-parent</artifactId>

                <version>1.3.2.RELEASE</version>

                <relativePath /> <!-- lookup parent from repository -->

          </parent>

          <dependencies>

                <dependency>

                      <groupId>org.springframework.boot</groupId>

                      <artifactId>spring-boot-starter</artifactId>

                </dependency>

                <dependency>

                      <groupId>org.springframework.boot</groupId>

                      <artifactId>spring-boot-starter-test</artifactId>

                      <scope>test</scope>

                </dependency>

                <dependency>

                      <groupId>org.mybatis.spring.boot</groupId>

                      <artifactId>mybatis-spring-boot-starter</artifactId>

                      <version>1.1.1</version>

                </dependency>

                <dependency>

                      <groupId>mysql</groupId>

                      <artifactId>mysql-connector-java</artifactId>

                      <version>5.1.21</version>

                </dependency>

                <dependency>

                      <groupId>org.springframework.boot</groupId>

                      <artifactId>spring-boot-starter-web</artifactId>

                </dependency>

          </dependencies>

    2)application.properties配置文件

    spring.datasource.url=jdbc:mysql://localhost:3306/test

    spring.datasource.username=root

    spring.datasource.password=root

    spring.datasource.driver-class-name=com.mysql.jdbc.Driver

    3)创建实体类,添加get和set方法

     

    3)通过实体类,创建调用方法

    4)创建访问路径

    5)创建启动类

    注意

    使用@MapperScan可以指定要扫描的Mapper类的包的路径

  • 相关阅读:
    java.security.InvalidKeyException: Illegal key size aes解密失败
    Java获取URL链接的文件类型
    解决eclipse中web项目出现Project facet Java version 1.8 is not supported.的问题
    探讨一下Java单例设计模式
    HTML5文件上传qq、百度、taobao等比较(改进支持三种状态提示)
    jQuery Ajax 上传文件改进
    Java POI 3.17写入、导入EXCEL性能测试
    jQuery Ajax 上传文件夹及文件
    Java 打包下载服务器上选中的文件或目录(带进度条提示)
    pio 背景色
  • 原文地址:https://www.cnblogs.com/JSWBK/p/8023636.html
Copyright © 2011-2022 走看看