库存服务的开发框架整合与搭建:spring boot+mybatis+jedis

整理的springboot思维导图:springboot

引入2.6.2版本springboot,对应java8,最高可支持java17,maven3.5,tomcat9版本

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.2</version>
    </parent>

  

以下应用程序启动器由该组下的Spring Boot提供:org.springframework.boot

 

spring-boot-starter

核心启动器,包括自动配置支持、日志记录和 YAML

spring-boot-starter-activemq

使用 Apache ActiveMQ 的 JMS 消息传递入门程序

spring-boot-starter-amqp

用于使用 Spring AMQP 和 Rabbit MQ 的启动器

spring-boot-starter-aop

使用Spring AOP和AspectJ进行面向方面的编程的入门程序

spring-boot-starter-artemis

使用Apache Artemis的JMS消息传递入门

spring-boot-starter-batch

使用春季批次的启动器

spring-boot-starter-cache

使用Spring框架缓存支持的入门

spring-boot-starter-data-cassandra

使用Cassandra分布式数据库和Spring Data Cassandra的入门

spring-boot-starter-data-cassandra-reactive

使用Cassandra分布式数据库和Spring Data Cassandra Reactive的入门程序

spring-boot-starter-data-couchbase

使用 Couchbase 面向文档的数据库和 Spring Data Couchbase 的入门

spring-boot-starter-data-couchbase-reactive

使用 Couchbase 面向文档的数据库和 Spring Data Couchbase Reactive 的入门

spring-boot-starter-data-elasticsearch

使用Elasticsearch搜索和分析引擎以及Spring Data Elasticsearch的入门

spring-boot-starter-data-jdbc

使用弹簧数据JDBC的入门程序

spring-boot-starter-data-jpa

将Spring Data JPA与Hibernate一起使用的入门程序

spring-boot-starter-data-ldap

使用弹簧数据 LDAP 的入门程序

spring-boot-starter-data-mongodb

使用MongoDB面向文档的数据库和Spring Data MongoDB的入门

spring-boot-starter-data-mongodb-reactive

使用MongoDB面向文档的数据库和Spring Data MongoDB Reactive的入门程序

spring-boot-starter-data-neo4j

使用Neo4j图形数据库和Spring Data Neo4j的入门

spring-boot-starter-data-r2dbc

使用弹簧数据R2DBC的启动器

spring-boot-starter-data-redis

将 Redis 键值数据存储与 Spring Data Redis 和 Lettuce 客户端结合使用的初学者

spring-boot-starter-data-redis-reactive

将 Redis 键值数据存储与 Spring Data Redis 反应式和生菜客户端结合使用的初学者

spring-boot-starter-data-rest

使用 Spring Data REST 在 REST 上公开 Spring Data 存储库的入门程序

spring-boot-starter-freemarker

使用 FreeMarker 视图构建 MVC Web 应用程序的初学者

spring-boot-starter-groovy-templates

使用 Groovy 模板视图构建 MVC Web 应用程序的初学者

spring-boot-starter-hateoas

使用Spring MVC和Spring HATEOAS构建基于超媒体的RESTful Web应用程序的入门程序

spring-boot-starter-integration

使用弹簧集成的入门程序

spring-boot-starter-jdbc

将 JDBC 与 HikariCP 连接池配合使用的入门程序

spring-boot-starter-jersey

使用 JAX-RS 和 Jersey 构建 RESTful Web 应用程序的入门程序。弹簧启动器-启动器-卷筒纸的替代方案

spring-boot-starter-jooq

使用 jOOQ 访问带有 JDBC 的 SQL 数据库的初学者。弹簧启动器-数据-jpa弹簧启动-启动-jdbc 的替代方法

spring-boot-starter-json

用于读取和编写 json 的初学者

spring-boot-starter-jta-atomikos

使用Atomikos的JTA交易的启动器

spring-boot-starter-mail

使用Java Mail和Spring Framework的电子邮件发送支持的入门

spring-boot-starter-mustache

使用 Mustache 视图构建 Web 应用程序的初学者

spring-boot-starter-oauth2-client

使用Spring Security的OAuth2 / OpenID Connect客户端功能的入门程序

spring-boot-starter-oauth2-resource-server

使用Spring Security的OAuth2资源服务器功能的入门程序

spring-boot-starter-quartz

使用石英调度程序的启动器

spring-boot-starter-rsocket

用于构建 RSocket 客户端和服务器的入门程序

spring-boot-starter-security

使用弹簧安全性的启动器

spring-boot-starter-test

用于测试Spring Boot应用程序的入门程序,包括JUnit Jupiter,Hamcrest和Mockito等库

spring-boot-starter-thymeleaf

使用 Thymeleaf 视图构建 MVC Web 应用程序的初学者

spring-boot-starter-validation

将 Java Bean Validation 与 Hibernate Validator 结合使用的初学者

spring-boot-starter-web

使用Spring MVC构建Web(包括RESTful)应用程序的入门程序。使用 Tomcat 作为默认嵌入式容器

spring-boot-starter-web-services

使用Spring Web服务的入门

spring-boot-starter-webflux

使用Spring Framework的Reactive Web支持构建WebFlux应用程序的入门者

spring-boot-starter-websocket

使用Spring Framework的WebSocket支持构建WebSocket应用程序的初学者

除了应用程序启动器之外,以下启动器还可用于添加生产就绪功能:

表 2.弹簧靴生产启动器
名字描述

spring-boot-starter-actuator

使用Spring Boot执行器的入门程序,该执行器提供生产就绪功能,可帮助您监控和管理应用程序

最后,Spring Boot还包括以下启动器,如果要排除或交换特定的技术方面,可以使用这些启动器:

表 3.弹簧靴技术启动器
名字描述

spring-boot-starter-jetty

使用 Jetty 作为嵌入式 servlet 容器的启动器。弹簧启动器雄猫的替代品

spring-boot-starter-log4j2

使用 Log4j2 进行日志记录的初学者。弹簧启动器日志记录的替代方案

spring-boot-starter-logging

使用日志返回进行日志记录的初学者。默认日志记录启动器

spring-boot-starter-reactor-netty

使用 Reactor Netty 作为嵌入式反应式 HTTP 服务器的入门者。

spring-boot-starter-tomcat

使用 Tomcat 作为嵌入式 servlet 容器的入门。弹簧启动器-启动器-web使用的默认 servlet 容器启动器

spring-boot-starter-undertow

用于使用 Undertow 作为嵌入式 Servlet 容器的启动器。弹簧启动器雄猫的替代品

要了解如何交换技术方面,请参阅交换 Web 服务器日志记录系统的操作方法文档。

==========================================================================================

springboot集成mybatis.pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.roncoo.eshop</groupId>
    <artifactId>eshop-inventory</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <name>eshop-inventory</name>
    <url>http://maven.apache.org</url>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.2</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

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

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


        <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.79</version>
        </dependency>
        <!--集成mysql数据库-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
         <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.1</version>
        </dependency>

    </dependencies>
</project>

  新建测试表

Application.properties

#集成mysql数据库的配置
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.31.200:3306/inventory?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=player3.
#配置mapper的扫描路径
mybatis.mapper-locations=classpath:mapper/*Dao.xml

#开启sql日志打印,com.springboot.MyMabatis——这是我自己的包名,按需修改
logging.level.com.roncoo.eshop.dao=debug

  启动类的配置:

@MapperScan("com.roncoo.eshop.dao")
 @SpringBootApplication
  public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
        System.out.println("启动成功");
    }

}

安装一个数据库的插件

本文来自博客园,作者:三号小玩家,转载请注明原文链接:https://www.cnblogs.com/q1359720840/p/15758888.html

原文地址:https://www.cnblogs.com/q1359720840/p/15758888.html