
SpringBoot
Springboot实战记录
天元白手
专精于企业数据分析、设计及实施商业智能业务解决方案、软件开发及数据管理和治理。
展开
-
springboot核心配置文件(不定期更新)
记录一些可能会使用到的配置#配置端口号server.port=8090# 配置服务名spring.application.name=service-acl# 环境设置:dev、test、prodspring.profiles.active=dev# 配置应用访问路径server.servlet.context-path=/bookManage# 日期格式配置spring.mvc.format.date=dd/MM/yyyy#返回json的全局时间格式spring.jacks原创 2021-06-26 21:32:45 · 147 阅读 · 0 评论 -
启动Springboot之后,执行某个方法,且不影响提供服务
第一种方式,应该也是最简单的方式使用 @PostConstruct,直接在方法上面注入,但是会影响服务提供,比如这个方法要执行五分钟 这五分钟之内是无法提供服务的,这个方法是在服务初始化后之前运行, 所以 此方法运行不结束,服务就无法初始化, 在这过程路也无法提供服务@SpringBootApplicationpublic class DemoApplication { public static void main(String[] args) { SpringApplic转载 2021-06-24 17:24:11 · 444 阅读 · 0 评论 -
java.lang.IllegalArgumentException: no server available
当我在测试springcloud的时候出现的问题:java.lang.IllegalArgumentException: no server available at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:354) ~[nacos-client-1.0.0.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(Namin原创 2021-05-08 22:26:38 · 8217 阅读 · 0 评论 -
springboot和SSM配置swagger笔记(笔记分享,亲测有效)
需要导入的架包: <!--swagger--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <scope>provided </scope> </dependency&g原创 2021-04-12 22:18:47 · 142 阅读 · 0 评论 -
easyExcel的读、写和导出图片(笔记分享)
一、Excel导入导出的应用场景1、数据导入:减轻录入工作量2、数据导出:统计信息归档3、数据传输:异构系统之间数据传递二、EasyExcel简介1、EasyExcel特点Java领域解析、生成Excel比较有名的框架有Apache poi、jxl等。但他们都存在一个严重的问题就是非常的耗内存。如果你的系统并发量不大的话可能还行,但是一旦并发上来后一定会OOM或者JVM频繁的full gc。EasyExcel是阿里巴巴开源的一个excel处理框架,以使用简单、节省内存著称。EasyExcel能原创 2021-04-22 14:59:04 · 11428 阅读 · 12 评论 -
MybatisPlus的逻辑删除
逻辑删除和物理删除的区别是:逻辑删除是假的删除,物理删除是真的删除。 //删除操作 物理删除 @Test public void testDeleteById(){ int i = userMapper.deleteById(1L); System.out.println(i); } //批量删除 @Test public void testDeleteBatchIds(){ int i = userMapper.deleteBatchIds(Ar原创 2021-04-11 18:16:22 · 742 阅读 · 0 评论 -
MybatisPlus性能分析插件
性能分析插件:(1)参数说明:参数:maxTime:Sql执行最长时长,超过自动停止运行,有助于发现问题。参数:format:SQL是否格式化,默认false(2)在MybatisPlusConfig中配置在这里需要注意的是新版的mp不支持这个插件,需要把mp降级到3.0.5/** * sql执行性能分析插件 * 开发环境使用,线上不推荐,maxTime是sql最大执行时长 * @return */ @Bean @Profile({"dev","test"}) /原创 2021-04-11 20:43:59 · 625 阅读 · 0 评论 -
Springboot统一返回结果工具类(笔记分享)
在日常开发中需要统一结果返回,将所有接口的数据格式封装格式统一,这样有利于前后端的开发,统一一个返回的结果模板,:/** * @author thunder * @version 1.0.0 * @description */public interface ResultCode { public static Integer SUCCESS = 20000; //成功 public static Integer ERROR = 20001; //失败}编辑返回结果的原创 2021-04-13 08:12:07 · 1089 阅读 · 0 评论 -
MybatisPlus实现复杂查询
mp实现复杂查询,使用queryWrapper构建条件,创建QueryWrapper构建条件,使用方法实现各种条件查询:1、ge大于等于、gt大于、le小于等于、lt小于、isNull、isNotNull //mp实现复杂查询 @Test public void testSelectQuery(){ QueryWrapper<User> wrapper = new QueryWrapper<>(); // 查询age >= 30记录原创 2021-04-11 21:24:16 · 1519 阅读 · 0 评论 -
MybatisPlus实现分页查询
首先预热:1、list集合//多个id批量查询 @Test void testSelect1(){ //这里的selectBatchIds方法 需要传入一个id的集合参数 List<User> users = userMapper.selectBatchIds(Arrays.asList(1L, 2L, 3L)); users.forEach(System.out::println); }2、map的方法 @Test void testSele原创 2021-04-11 17:25:20 · 3427 阅读 · 0 评论 -
MybatisPlus的乐观锁(笔记分享)
乐观锁主要解决的问题是:丢失更新。多个人同时修改同一条数据,最后提交的把之前提交的数据覆盖这是一个问题。解决方案:悲观锁:“串行”,有人已修改数据就上锁,只有前面的人修改了之后,才能下一个人再修改乐观锁:主要适用场景:当更新一条数据的时候,希望这条记录没有被别人更新,也就是说实现线程安全的数据更新乐观锁实现方式:取出记录时,获取当前version更新时,带上这个version执行更新时,set version=newVersion where version=oldVersion如果v原创 2021-04-11 16:54:47 · 405 阅读 · 0 评论 -
thymeleaf入门基础语法笔记
记录一下,等做项目的时候不需要满世界的百度查语法在使用thymeleaf的时候我们需要在html页面的头顶加入thymeleaf的命名空间<html xmlns:th="http://www.thymeleaf.org"><html xmlns:th="http://www.thymeleaf.org"> <head> <title>Good Thymes Virtual Grocery</title> <met原创 2021-02-28 13:32:04 · 566 阅读 · 0 评论 -
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [outbound], template might
使用thymeleaf错误Error resolving template [outbound], template might not exist or might not be accessible by any of the configured Template ResolversError resolving template [outbound], template might not exist or might not be accessible by any of the config原创 2021-03-25 18:49:20 · 746 阅读 · 0 评论 -
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.thunder.mapper.
当你出现这个错误的时候,我建议你检查两个地方:1、mapper存放的位置2、mybatis-plus.mapper-locations或者mybatis.mapper-locations配置的路径org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.thunder.mapper.ProjectMapper.getAll at com.baomidou.mybatisplus.core原创 2021-03-15 21:23:38 · 156 阅读 · 0 评论 -
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘pro
当我在使用mybatisPlus逆向创建项目的时候加入pagehelper之后碰到的问题: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =原创 2021-03-09 23:03:28 · 2193 阅读 · 0 评论 -
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.thunder.service
今天使用springboot+mybatis-plus逆向工程的时候,编辑测试类获取后端数据碰到的问题:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.thunder.service.SaleService.getBaseMapper at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMe原创 2021-03-07 11:56:29 · 309 阅读 · 2 评论 -
宠物管理系统springboot+mybatisPlus+thymeleaf+js+jQuery
首先使用mybatis-plus生成代码再引入pom.xml依赖<?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 https:原创 2021-03-05 20:30:12 · 205 阅读 · 0 评论 -
会议室管理系统springboot+thymeleaf+mybatis-Plus
会议室管理系统架包图片首先配置好pom.xml文件,再使用mybatisPlus生成代码,所有的实体类,mapper,service,controller都可以生成pom.xml<?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" x原创 2021-03-04 19:37:37 · 637 阅读 · 0 评论 -
mybatisPlus运行出错org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean
报错信息: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/原创 2021-03-03 22:42:03 · 3653 阅读 · 5 评论 -
花卉管理系统springboot
视图pom.xml文件<?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 https://maven.apache.org/x原创 2021-03-03 19:56:17 · 799 阅读 · 0 评论 -
springboot的@Value 的map注入
首先在properties里写好map注入的文件:#注入mapmaps={'a':'aa','b':'bb','c':'cc'}之后使用@Value注入:package com.baizhi.demo.controller;import com.baizhi.demo.config.User;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.facto原创 2021-02-26 20:29:01 · 5162 阅读 · 0 评论 -
springboot的@value的注入案例
在properties的配置:server.port=8088server.servlet.context-path=/springbootname=xiaochenbir=2020/02/03在java类里的引用:package com.baizhi.demo.controller;import com.baizhi.demo.config.User;import org.springframework.beans.factory.annotation.Autowired;imp原创 2021-02-26 08:42:30 · 148 阅读 · 0 评论 -
springboot自定义图标banner
如果你也想自己制作请点击下面的链接:链接跳转原创 2021-02-24 23:27:14 · 199 阅读 · 0 评论 -
Failed to bind properties under ‘spring.datasource‘ to javax.sql.DataSource
发现问题:Failed to bind properties under ‘spring.datasource’ to javax.sql.DataSource:翻译过来的意思是未能绑定“”下的属性spring.datasource’到javax.sql.DataSource发现好像少了点什么…解决方案:试一下在pom.xml里面加入<dependency> <groupId>log4j</groupId>原创 2020-07-11 21:27:27 · 459 阅读 · 0 评论 -
springboot2.3.1替换为其他的嵌入式servlet容器
现阶段,springboot内嵌了Tomcat服务器,如果你不想使用Tomcat,springboot也是支持其他的服务器切换的。如果你想了解底层springboot所支持的服务器你可以使用idea的快捷键快速按两次shift查询一个ServerProperties 的类,通过这个类你可以知道你想要了解的情况:springboot里面支持的服务器有Jetty、Netty…等等,大家有兴趣的话可以百度一下。接着通过在pom文件的视图依赖分析可以得知:springboot里面的Tomcat是在spr原创 2020-07-09 13:52:23 · 410 阅读 · 4 评论 -
修改Springboot网页标题的小图标
在修改的时候可以使用<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>首页</title> <link rel="icon" type="image/x-icon" href="favicon.ico"></head><body><h1>欢迎您!</h1>原创 2020-07-06 10:10:50 · 2239 阅读 · 1 评论 -
SpringBoot快速入门案例(通俗易懂老少皆宜的案例)
快速入门只需要五步就可以实现了第一步创建一个简单的maven工程(不需要加入web的支持的):在这里直接next就可以了第二步在你的pom.xml添加Springboot的起步依赖 <!--Springboot的起步依赖--> <parent> <artifactId>spring-boot-starter-parent</artifactId> <groupId>org.springframe原创 2020-06-17 10:01:15 · 344 阅读 · 0 评论