1 Star 0 Fork 0

dzq / BootDemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

BootDemo

SpringBoot Demo是一个集成了SpringBoot+MyBatis的Demo工程,以书籍数据管理为例提供了书籍的增删改查的Restfull格式的API接口。

开发环境

IDEA 2019.3 MySQL 8.0.19 Tomcat 9 Maven 3.6

目录结构

├── src                                                           # 
│   └── main                                                      # 
│       ├── java                                                  # 
│       │   └── com                                               # 
│       │       └── dzq                                           # 
│       │           └── bootdemo                                  # 
│       │               ├── Application.java                      # 程序入口
│       │               ├── SwaggerConfig.java                    # Swagger配置
│       │               ├── controller                            # 
│       │               │   └── BookAPIController.java            # 书籍增删改查API
│       │               ├── dao                                   # 
│       │               │   ├── BookMapper.java                   # 书籍Mapper接口
│       │               ├── pojo                                  # 
│       │               │   └── Books.java                        # 书籍数据模型
│       │               ├── service                               # 
│       │               │   ├── BookService.java                  # 书籍Service接口
│       │               │   └── BookServiceImpl.java              # 书籍Service实现
│       │               └── vo                                    # 
│       │                   └── ResponseBody.java                 # 返回对象
│       └── resources                                             # 
│           └── application.yaml                                  # SpringBoot配置文件
├── BootDemo.iml                                                  # 
├── LICENSE                                                       # 
├── README.md                                                     # 
├── pom.xml                                                       # 

数据库

CREATE DATABASE `ssmbuild`;

USE `ssmbuild`;
create table books
(
	id int auto_increment comment '书id'
		primary key,
	name varchar(100) not null comment '书名',
	num int not null comment '数量',
	detail varchar(200) not null comment '描述'
)
charset=utf8;


INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (1, 'Java', 1, '从入门到放弃');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (2, 'MySQL', 10, '从删库到跑路');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (3, 'Linux', 5, '从进门到进牢');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (4, '安慰我', 100, '大声道撒');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (5, 'MySQL', 10, '从删库到跑路');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (6, 'Linux', 5, '从进门到进牢');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (7, 'Java', 1, '从入门到放弃');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (8, 'MySQL', 10, '从删库到跑路');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (9, 'Linux', 5, '从进门到进牢');
INSERT INTO ssmbuild.books (id, name, num, detail) VALUES (10, '阿斯顿撒', 1, '实时');

Maven项目

pom依赖

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
    </parent>
    <dependencies>
        <!--  Spring Boot      -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--数据库驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.19</version>
        </dependency>
        <!-- 数据库连接池 -->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/tk.mybatis/mapper-spring-boot-starter -->
                <dependency>
                    <groupId>tk.mybatis</groupId>
                    <artifactId>mapper-spring-boot-starter</artifactId>
                    <version>2.0.3</version>
                </dependency>

        <!-- JSON-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.9.5</version>
        </dependency>
        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
            <scope>provided</scope>
        </dependency>
        <!--      Swagger-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
    </dependencies>

Maven资源过滤设置

<resources>
       <resource>
           <directory>src/main/java</directory>
           <includes>
               <include>**/*.properties</include>
               <include>**/*.xml</include>
           </includes>
           <filtering>true</filtering>
       </resource>
   </resources>

Spring Boot 配置文件

logging:
 level:
   root: info
   com.dzq.bootdemo: debug
spring:
 datasource:
   type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
   driver-class-name: com.mysql.cj.jdbc.Driver
   url: jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
   username: root
   password: 12345678
mybatis:
 mapper-locations: classpath:com/dzq/bootdemo/dao/*.xml
 type-aliases-package: com.dzq.bootdemo.pojo

提供的接口

POST /book 添加书籍
PUT /book 更新书籍
GET /book/{id} 查询指定ID的书籍
DELETE /book/{id} 删除书籍
GET /book/list 查询所有书籍
GET /book/search/{name} 查询包含指定名称书籍
MIT License Copyright (c) 2020 dzq Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

SpringBoot Demo是一个集成了SpringBoot+MyBatis的示例工程,以书籍数据管理为例提供了书籍的增删改查的Restfull格式的API接口 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/duzengqiang/BootDemo.git
git@gitee.com:duzengqiang/BootDemo.git
duzengqiang
BootDemo
BootDemo
master

搜索帮助