每天在用SpringBoot,但有些SpringBoot的实用知识点却不是很清楚!最近又对SpringBoot中的实用知识点作了个总结,相信对从Spring过渡到SpringBoot的朋友会颇有帮助!
SpringBoot实战电商项目mall(40k+star)地址:https://github.com/macrozheng/mallcss
首先咱们来了解下为何要有SpringBoot?html
Spring做为J2EE的轻量级代替品,让咱们无需开发重量级的Enterprise JavaBean(EJB),经过依赖注入和面向切面编程,使用简单的Java对象(POJO)便可实现EJB的功能。java
虽然Spring的组件代码是轻量级的,但它的配置倒是重量级的。即便后来Spring引入了基于注解的组件扫描和基于Java的配置,让它看上去简洁很多,但Spring仍是须要很多配置。除此以外,项目的依赖管理也很麻烦,咱们没法确保各个版本的依赖都能兼容。mysql
为了简化Spring中的配置和统一各类依赖的版本,SpringBoot诞生了!git
SpringBoot从本质上来讲就是Spring,它经过了一些本身的特性帮助咱们简化了Spring应用程序的开发。主要有如下三个核心特性:github
建立SpringBoot应用的方式有不少种,这里使用最流行的开发工具IDEA来建立应用。
File->New Project
来建立一个项目;Spring Initializr
来建立一个SpringBoot应用;groupId
和artifactId
及选择好Java版本;一个新建立的SpringBoot应用基本结构以下。web
mall-tiny-boot ├─pom.xml # Maven构建文件 └─src ├─main │ ├─java │ │ └─MallTinyApplication.java # 应用程序启动类 │ └─resources │ └─application.yml # SpringBoot配置文件 └─test └─java └─MallTinyApplicationTests.java # 基本的集成测试类
MallTinyApplication
在SpringBoot应用中有配置和引导的做用,经过@SpringBootApplication
注解开启组件扫描和自动配置,经过SpringApplication.run()
引导应用程序启动;redis
//开启组件扫描和应用装配 @SpringBootApplication public class MallTinyApplication { public static void main(String[] args) { //负责引导应用程序启动 SpringApplication.run(MallTinyApplication.class, args); } }
@SpringBootApplication
注解是三个注解的结合体,拥有如下三个注解的功能:spring
@Configuration
:用于声明Spring中的Java配置;@ComponentScan
:启用组件扫描,当咱们声明组件时,会自动发现并注册为Spring应用上下文中的Bean;@EnableAutoConfiguration
:开启SpringBoot自动配置功能,简化配置编写。可使用@RunWith
和@SpringBootTest
来建立Spring应用上下文,经过@Test
注解来声明一个测试方法。sql
@RunWith(SpringRunner.class) @SpringBootTest @Slf4j public class MallTinyApplicationTests { @Autowired private PmsBrandService pmsBrandService; @Test public void contextLoads() { } @Test public void testMethod() { List<PmsBrand> brandList = pmsBrandService.listAllBrand(); log.info("testMethod:{}", brandList); } }
当咱们须要微调自动配置的参数时,能够在application.yml
文件中进行配置,好比微调下端口号。
server: port: 8088
SpringBoot项目可使用Maven进行构建,首先咱们须要继承spring-boot-starter-parent
这个父依赖,父依赖能够控制全部SpringBoot官方起步依赖的版本,接下来当咱们使用官方起步依赖时,就不用指定版本号了。咱们还须要使用SpringBoot的插件,该插件主要用于将应用打包为可执行Jar。
<?xml version="1.0" encoding="UTF-8"?> <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.macro.mall</groupId> <artifactId>mall-tiny-boot</artifactId> <version>1.0-SNAPSHOT</version> <name>mall-tiny-boot</name> <description>Demo project for Spring Boot</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <skipTests>true</skipTests> </properties> <!--继承SpringBoot父项目,控制全部依赖版本--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <!--SpringBoot起步依赖--> <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> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <!--SpringBoot插件,能够把应用打包为可执行Jar--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
在使用起步依赖以前,咱们先来了解下使用起步依赖的好处,当咱们使用SpringBoot须要整合Web相关功能时,只需在pom.xml
中添加一个起步依赖便可。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
若是是Spring项目的话,咱们须要添加不少依赖,还须要考虑各个依赖版本的兼容性问题,是个至关麻烦的事情。
当咱们须要开发一个Web应用,须要使用MySQL数据库进行存储,使用Swagger生成API文档,添加以下起步依赖便可。须要注意的是只有官方的起步依赖不须要指定版本号,其余的仍是须要自行指定的。
<dependencies> <!--SpringBoot Web功能起步依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!--MyBatis分页插件--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.10</version> </dependency> <!--集成druid链接池--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.10</version> </dependency> <!--Mysql数据库驱动--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.15</version> </dependency> <!--springfox swagger官方Starter--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> </dependencies>
其实起步依赖和你平时使用的依赖没什么区别,你可使用Maven的方式来排除不想要的依赖。好比你不想使用tomcat容器,想使用undertow容器,能够在Web功能依赖中排除掉tomcat。
<dependencies> <!--SpringBoot Web功能起步依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <!--排除tomcat依赖--> <exclusion> <artifactId>spring-boot-starter-tomcat</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> </exclusions> </dependency> <!--undertow容器--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency> </dependencies>
SpringBoot的自动配置是一个运行时(更准确地说,是应用程序启动时)的过程,考虑了众多因素,才决定Spring配置应该用哪一个,不应用哪一个。
举个例子,当咱们使用Spring整合MyBatis的时候,须要完成以下几个步骤:
当咱们使用SpringBoot整合MyBatis的时候,会自动建立dataSource和sqlSessionFactory对象,只需咱们在application.yml
和Java配置中添加一些自定义配置便可。
在application.yml
中配置好数据库链接信息及mapper.xml文件路径。
spring: datasource: url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai username: root password: root mybatis: mapper-locations: - classpath:mapper/*.xml - classpath*:com/**/mapper/*.xml
使用Java配置,配置好mapper接口路径。
/** * MyBatis配置类 * Created by macro on 2019/4/8. */ @Configuration @MapperScan("com.macro.mall.tiny.mbg.mapper") public class MyBatisConfig { }
使用自动配置之后,咱们整合其余功能的配置大大减小了,能够更加专一程序功能的开发了。
虽然自动配置很好用,但有时候自动配置的Bean并不能知足你的须要,咱们能够本身定义相同的Bean来覆盖自动配置中的Bean。
例如当咱们使用Spring Security来保护应用安全时,因为自动配置并不能知足咱们的需求,咱们须要自定义基于WebSecurityConfigurerAdapter的配置。这里咱们自定义了不少配置,好比将基于Session的认证改成使用JWT令牌、配置了一些路径的无受权访问,自定义了登陆接口路径,禁用了csrf功能等。
/** * SpringSecurity的配置 * Created by macro on 2018/4/26. */ @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UmsAdminService adminService; @Autowired private RestfulAccessDeniedHandler restfulAccessDeniedHandler; @Autowired private RestAuthenticationEntryPoint restAuthenticationEntryPoint; @Autowired private IgnoreUrlsConfig ignoreUrlsConfig; @Override protected void configure(HttpSecurity httpSecurity) throws Exception { List<String> urls = ignoreUrlsConfig.getUrls(); String[] urlArray = ArrayUtil.toArray(urls, String.class); httpSecurity.csrf()// 因为使用的是JWT,咱们这里不须要csrf .disable() .sessionManagement()// 基于token,因此不须要session .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .authorizeRequests() .antMatchers(HttpMethod.GET,urlArray) // 容许对于网站静态资源的无受权访问 .permitAll() .antMatchers("/admin/login")// 对登陆注册要容许匿名访问 .permitAll() .antMatchers(HttpMethod.OPTIONS)//跨域请求会先进行一次options请求 .permitAll() .anyRequest()// 除上面外的全部请求所有须要鉴权认证 .authenticated(); // 禁用缓存 httpSecurity.headers().cacheControl(); // 添加JWT filter httpSecurity.addFilterBefore(jwtAuthenticationTokenFilter(), UsernamePasswordAuthenticationFilter.class); //添加自定义未受权和未登陆结果返回 httpSecurity.exceptionHandling() .accessDeniedHandler(restfulAccessDeniedHandler) .authenticationEntryPoint(restAuthenticationEntryPoint); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService()) .passwordEncoder(passwordEncoder()); } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Bean public UserDetailsService userDetailsService() { //获取登陆用户信息 return username -> { AdminUserDetails admin = adminService.getAdminByUsername(username); if (admin != null) { return admin; } throw new UsernameNotFoundException("用户名或密码错误"); }; } @Bean public JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter() { return new JwtAuthenticationTokenFilter(); } @Bean @Override public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); } }
有时候咱们只须要微调下自动配置就能知足需求,并不须要覆盖自动配置的Bean,此时咱们能够在application.yml
属性文件中进行配置。
好比微调下应用运行的端口。
server: port: 8088
好比修改下数据库链接信息。
spring: datasource: url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai username: root password: root
有时候咱们会在属性文件中自定义一些属性,而后在程序中使用。此时能够将这些自定义属性映射到一个属性类里来使用。
好比说咱们想给Spring Security配置一个白名单,访问这些路径无需受权,咱们能够先在application.yml
中添添加以下配置。
secure: ignored: urls: - / - /swagger-ui/ - /*.html - /favicon.ico - /**/*.html - /**/*.css - /**/*.js - /swagger-resources/** - /v2/api-docs/**
以后建立一个属性类,使用@ConfigurationProperties
注解配置好这些属性的前缀,再定义一个urls
属性与属性文件相对应便可。
/** * 用于配置白名单资源路径 * Created by macro on 2018/11/5. */ @Getter @Setter @Component @ConfigurationProperties(prefix = "secure.ignored") public class IgnoreUrlsConfig { private List<String> urls = new ArrayList<>(); }
SpringBoot Actuator的关键特性是在应用程序里提供众多Web端点,经过它们了解应用程序运行时的内部情况。
Actuator提供了大概20个端点,经常使用端点路径及描述以下:
路径 | 请求方式 | 描述 |
---|---|---|
/beans | GET | 描述应用程序上下文里所有的Bean,以及它们之间关系 |
/conditions | GET | 描述自动配置报告,记录哪些自动配置生效了,哪些没生效 |
/env | GET | 获取所有环境属性 |
/env/{name} | GET | 根据名称获取特定的环境属性 |
/mappings | GET | 描述所有的URI路径和控制器或过滤器的映射关系 |
/configprops | GET | 描述配置属性(包含默认值)如何注入Bean |
/metrics | GET | 获取应用程序度量指标,好比JVM和进程信息 |
/metrics/{name} | GET | 获取指定名称的应用程序度量值 |
loggers | GET | 查看应用程序中的日志级别 |
/threaddump | GET | 获取线程活动的快照 |
/health | GET | 报告应用程序的健康指标,这些值由HealthIndicator的实现类提供 |
/shutdown | POST | 关闭应用程序 |
/info | GET | 获取应用程序的定制信息,这些信息由info打头的属性提供 |
{ "_links": { "self": { "href": "http://localhost:8088/actuator", "templated": false }, "beans": { "href": "http://localhost:8088/actuator/beans", "templated": false }, "caches-cache": { "href": "http://localhost:8088/actuator/caches/{cache}", "templated": true }, "caches": { "href": "http://localhost:8088/actuator/caches", "templated": false }, "health": { "href": "http://localhost:8088/actuator/health", "templated": false }, "health-path": { "href": "http://localhost:8088/actuator/health/{*path}", "templated": true }, "info": { "href": "http://localhost:8088/actuator/info", "templated": false }, "conditions": { "href": "http://localhost:8088/actuator/conditions", "templated": false }, "configprops": { "href": "http://localhost:8088/actuator/configprops", "templated": false }, "env": { "href": "http://localhost:8088/actuator/env", "templated": false }, "env-toMatch": { "href": "http://localhost:8088/actuator/env/{toMatch}", "templated": true }, "loggers": { "href": "http://localhost:8088/actuator/loggers", "templated": false }, "loggers-name": { "href": "http://localhost:8088/actuator/loggers/{name}", "templated": true }, "heapdump": { "href": "http://localhost:8088/actuator/heapdump", "templated": false }, "threaddump": { "href": "http://localhost:8088/actuator/threaddump", "templated": false }, "metrics-requiredMetricName": { "href": "http://localhost:8088/actuator/metrics/{requiredMetricName}", "templated": true }, "metrics": { "href": "http://localhost:8088/actuator/metrics", "templated": false }, "scheduledtasks": { "href": "http://localhost:8088/actuator/scheduledtasks", "templated": false }, "mappings": { "href": "http://localhost:8088/actuator/mappings", "templated": false } } }
/beans
端点,能够获取到Spring应用上下文中的Bean的信息,好比Bean的类型和依赖属性等,访问地址:http://localhost:8088/actuator/beans{ "contexts": { "application": { "beans": { "sqlSessionFactory": { "aliases": [], "scope": "singleton", "type": "org.apache.ibatis.session.defaults.DefaultSqlSessionFactory", "resource": "class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]", "dependencies": [ "dataSource" ] }, "jdbcTemplate": { "aliases": [], "scope": "singleton", "type": "org.springframework.jdbc.core.JdbcTemplate", "resource": "class path resource [org/springframework/boot/autoconfigure/jdbc/JdbcTemplateConfiguration.class]", "dependencies": [ "dataSource", "spring.jdbc-org.springframework.boot.autoconfigure.jdbc.JdbcProperties" ] } } } } }
/conditions
端点,能够获取到当前应用的自动配置报告,positiveMatches
表示生效的自动配置,negativeMatches
表示没有生效的自动配置。{ "contexts": { "application": { "positiveMatches": { "DruidDataSourceAutoConfigure": [{ "condition": "OnClassCondition", "message": "@ConditionalOnClass found required class 'com.alibaba.druid.pool.DruidDataSource'" }] }, "negativeMatches": { "RabbitAutoConfiguration": { "notMatched": [{ "condition": "OnClassCondition", "message": "@ConditionalOnClass did not find required class 'com.rabbitmq.client.Channel'" }], "matched": [] } } } } }
/env
端点,能够获取所有配置属性,包括环境变量、JVM属性、命令行参数和application.yml
中的属性。{ "activeProfiles": [], "propertySources": [{ "name": "systemProperties", "properties": { "java.runtime.name": { "value": "Java(TM) SE Runtime Environment" }, "java.vm.name": { "value": "Java HotSpot(TM) 64-Bit Server VM" }, "java.runtime.version": { "value": "1.8.0_91-b14" } } }, { "name": "applicationConfig: [classpath:/application.yml]", "properties": { "server.port": { "value": 8088, "origin": "class path resource [application.yml]:2:9" }, "spring.datasource.url": { "value": "jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai", "origin": "class path resource [application.yml]:6:10" }, "spring.datasource.username": { "value": "root", "origin": "class path resource [application.yml]:7:15" }, "spring.datasource.password": { "value": "******", "origin": "class path resource [application.yml]:8:15" } } } ] }
/mappings
端点,能够查看所有的URI路径和控制器或过滤器的映射关系,这里能够看到咱们本身定义的PmsBrandController
和JwtAuthenticationTokenFilter
的映射关系。{ "contexts": { "application": { "mappings": { "dispatcherServlets": { "dispatcherServlet": [{ "handler": "com.macro.mall.tiny.controller.PmsBrandController#createBrand(PmsBrand)", "predicate": "{POST /brand/create}", "details": { "handlerMethod": { "className": "com.macro.mall.tiny.controller.PmsBrandController", "name": "createBrand", "descriptor": "(Lcom/macro/mall/tiny/mbg/model/PmsBrand;)Lcom/macro/mall/tiny/common/api/CommonResult;" }, "requestMappingConditions": { "consumes": [], "headers": [], "methods": [ "POST" ], "params": [], "patterns": [ "/brand/create" ], "produces": [] } } }] } }, "servletFilters": [{ "servletNameMappings": [], "urlPatternMappings": [ "/*", "/*", "/*", "/*", "/*" ], "name": "jwtAuthenticationTokenFilter", "className": "com.macro.mall.tiny.component.JwtAuthenticationTokenFilter" }] } } }
/metrics
端点,能够获取应用程序度量指标,不过只能获取度量的名称;{ "names": [ "http.server.requests", "jvm.buffer.count", "jvm.buffer.memory.used", "jvm.buffer.total.capacity", "jvm.classes.loaded", "jvm.classes.unloaded", "jvm.gc.live.data.size", "jvm.gc.max.data.size", "jvm.gc.memory.allocated", "jvm.gc.memory.promoted", "jvm.gc.pause", "jvm.memory.committed", "jvm.memory.max", "jvm.memory.used", "jvm.threads.daemon", "jvm.threads.live", "jvm.threads.peak", "jvm.threads.states", "logback.events", "process.cpu.usage", "process.start.time", "process.uptime", "system.cpu.count", "system.cpu.usage" ] }
{ "name": "jvm.memory.used", "description": "The amount of used memory", "baseUnit": "bytes", "measurements": [ { "statistic": "VALUE", "value": 3.45983088E8 } ], "availableTags": [ { "tag": "area", "values": [ "heap", "nonheap" ] }, { "tag": "id", "values": [ "Compressed Class Space", "PS Survivor Space", "PS Old Gen", "Metaspace", "PS Eden Space", "Code Cache" ] } ] }
loggers
端点,能够查看应用程序中的日志级别信息,能够看出咱们把ROOT
范围日志设置为了INFO,而com.macro.mall.tiny
包范围的设置为了DEBUG。{ "levels": [ "OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" ], "loggers": { "ROOT": { "configuredLevel": "INFO", "effectiveLevel": "INFO" }, "com.macro.mall.tiny": { "configuredLevel": "DEBUG", "effectiveLevel": "DEBUG" } } }
/health
端点,能够查看应用的健康指标。{ "status": "UP" }
经过POST请求/shutdown
端点能够直接关闭应用,可是须要将endpoints.shutdown.enabled
属性设置为true才可使用。
{ "message": "Shutting down, bye..." }
有的时候,咱们须要自定义一下Actuator的端点才能知足咱们的需求。
management: endpoints: web: exposure: include: '*'
/monitor
,这样咱们咱们访问地址就变成了这个:http://localhost:8088/monitormanagement: endpoints: web: base-path: /monitor
起步依赖不只能让构建应用的依赖配置更简单,还能根据提供给应用程序的功能将它们组织到一块儿,这里整理了一些经常使用的起步依赖。
<dependencies> <!--SpringBoot整合Web功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--SpringBoot整合Actuator功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!--SpringBoot整合AOP功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!--SpringBoot整合测试功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!--SpringBoot整合注解处理功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <!--SpringBoot整合Spring Security安全功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!--SpringBoot整合Redis数据存储功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!--SpringBoot整合Elasticsearch数据存储功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> <!--SpringBoot整合MongoDB数据存储功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <!--SpringBoot整合AMQP消息队列功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> <!--SpringBoot整合Quartz定时任务功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-quartz</artifactId> </dependency> <!--SpringBoot整合JPA数据存储功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <!--SpringBoot整合邮件发送功能依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> </dependencies>
<dependencies> <!--SpringBoot整合MyBatis数据存储功能依赖--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-version.version}</version> </dependency> <!--SpringBoot整合PageHelper分页功能依赖--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>${pagehelper-starter.version}</version> </dependency> <!--SpringBoot整合Druid数据库链接池功能依赖--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>${druid.version}</version> </dependency> <!--SpringBoot整合Springfox的Swagger API文档功能依赖--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>${springfox-version}</version> </dependency> <!--SpringBoot整合MyBatis-Plus数据存储功能依赖--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus-version}</version> </dependency> <!--SpringBoot整合Knife4j API文档功能依赖--> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>${knife4j-version}</version> </dependency> </dependencies>
https://github.com/macrozheng...
本文 GitHub https://github.com/macrozheng/mall-learning 已经收录,欢迎你们Star!