zoukankan      html  css  js  c++  java
  • springboot+jpa+mysql+swagger2.0整合

    Springboot+jpa+MySQL+swagger整合

    创建一个springboot web项目

    <dependencies>

       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
       </dependency>

       <!-- 下面两个引入为了操作数据库 -->
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
       </dependency>
       <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
       </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
          <scope>provided</scope>
       </dependency>
       <!-- 只需引入spring-boot-devtools 即可实现热部署 -->
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-devtools</artifactId>
       </dependency>
       <!-- Json -->
       <dependency>
          <groupId>com.alibaba</groupId>
          <artifactId>fastjson</artifactId>
          <version>1.2.16</version>
       </dependency>

       <!-- 为了监控数据库 -->
       <dependency>
          <groupId>com.alibaba</groupId>
          <artifactId>druid</artifactId>
          <version>1.0.25</version>
       </dependency>

       <dependency>
          <groupId>org.apache.poi</groupId>
          <artifactId>poi</artifactId>
          <version>3.14</version>
       </dependency>

       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
       </dependency>

       <!-- swagger2 -->
       <dependency>
          <groupId>io.springfox</groupId>
          <artifactId>springfox-swagger2</artifactId>
          <version>2.8.0</version>
       </dependency>
       <dependency>
          <groupId>io.springfox</groupId>
          <artifactId>springfox-swagger-ui</artifactId>
          <version>2.8.0</version>
       </dependency>
       <dependency>
          <groupId>io.swagger</groupId>
          <artifactId>swagger-annotations</artifactId>
          <version>1.5.14</version>
       </dependency>

       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
       </dependency>

       <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.8.2</version>
       </dependency>

       <dependency>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId>
       </dependency>


    </dependencies>

     

    二、添加swagger的资源文件,配置application.yml文件

     

    三、配置swagger

     

     

     

    Swagger访问的路径:

     

    Postman访问的路径:

     

    SpringBoot  Jpa使用

  • 相关阅读:
    最新 蓝鲸人java校招面经 (含整理过的面试题大全)
    最新 上海轻轻java校招面经 (含整理过的面试题大全)
    最新 苏州朗动java校招面经 (含整理过的面试题大全)
    最新 医渡云java校招面经 (含整理过的面试题大全)
    变量的自动类型转换和强制类型转换(day01_10)
    java的数据类型(day01_09)
    常用的dos命令操作(day01_03)
    1.镜像-虚拟光驱-光驱
    Spring基于配置文件的方式来配置AOP
    Spring-AOP(切面的优先级&&&重用切点表达式)
  • 原文地址:https://www.cnblogs.com/xiqoqu/p/9621719.html
Copyright © 2011-2022 走看看