随笔分类 -  SpringBoot

SpringBoot开发笔记
摘要:SpringBoot项目使用Junit进行单元测试 环境:Springboot 2.6.7 POM.xml文件 添加如下内容: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-start 阅读全文 »
posted @ 2023-04-25 22:34 zolmk 阅读(117) 评论(0) 推荐(0) 编辑
摘要:使用Maven-shade-plugin打包SpringBoot项目 另附参考文章:https://blog.csdn.net/u011441473/article/details/127844885 好奇葩的打包之旅,最后在stack overflow上找到了解决办法,遇到问题,还是多去googl 阅读全文 »
posted @ 2023-04-22 18:34 zolmk 阅读(882) 评论(0) 推荐(0) 编辑
摘要:Spring Boot Security (三) 之前的随笔(https://www.cnblogs.com/zolmk/p/14074227.html)简单的使用了Spring Boot Security,没有深入。 一、主要内容 这篇主要的应用场景为前后端分离,前端Vue,后端Spring Bo 阅读全文 »
posted @ 2023-04-22 16:52 zolmk 阅读(168) 评论(0) 推荐(0) 编辑
摘要:Spring Boot 配置引发 时区问题,接口返回日期莫名其妙-1天? 如果像这篇文章(https://www.cnblogs.com/zolmk/p/16452157.html) 一样配置 MessageConverter 会引发一个莫名其妙的时区问题,如:接口返回日期被-1天。 修改方式如下, 阅读全文 »
posted @ 2022-08-17 21:37 zolmk 阅读(347) 评论(0) 推荐(0) 编辑
摘要:SpringBoot 过滤器和拦截器 实现全局接口日志输出 首先,看一张图: Tomcat收到请求之后,会先通过过滤器 Filter,该过滤器属于 Java Http 框架(过滤器采用接口回调的方式来运行);然后请求被发送的 Servlet,SpringBoot收到请求之后,调用拦截器 Interc 阅读全文 »
posted @ 2022-08-14 20:41 zolmk 阅读(2421) 评论(0) 推荐(2) 编辑
摘要:解决 SpringBoot配置全局的fastxml转换器——引发 Hibernate事务同步错误: Cloud not obtain synchronized-ransaction Session for current thread 参考https://www.cnblogs.com/zolmk/ 阅读全文 »
posted @ 2022-07-06 19:11 zolmk 阅读(265) 评论(0) 推荐(0) 编辑
摘要:SpringBoot中Jackson的使用:注册全局的序列化和反序列化器 注:此种方式会引发Hibernate事务同步问题,虽然修改的是接口层,但是会影响DAO层,修改建议如下: https://www.cnblogs.com/zolmk/p/16452157.html 什么情况下会用到? 当我们需 阅读全文 »
posted @ 2022-07-02 01:52 zolmk 阅读(1529) 评论(0) 推荐(0) 编辑
摘要:Spring Boot项目添加全局异常捕获器 示例代码如下: @RestControllerAdvice public class GlobalExceptionHandler{ @ExceptionHandler(value = Exception.class) public Result<?> 阅读全文 »
posted @ 2022-05-28 12:37 zolmk 阅读(70) 评论(0) 推荐(0) 编辑
摘要:SpringBoot中的表单校验 一、添加依赖 请注意,不添加依赖编译不会报错,但是校验注解不会生效! <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> </depende 阅读全文 »
posted @ 2022-05-28 12:30 zolmk 阅读(367) 评论(0) 推荐(0) 编辑
摘要:Spring Boot\Cloud Maven项目版本管理问题 前述:Spring Boot和Spring Cloud如果配置的时候不注意版本,就会出现各种各样奇奇怪怪的问题,手动管理项目依赖太麻烦。 使用Maven中的DependenciesManager节点来管理版本 一般常用的有下面三个: < 阅读全文 »
posted @ 2022-05-03 20:38 zolmk 阅读(458) 评论(0) 推荐(0) 编辑
摘要:SpringBoot 集成 Shiro 一、添加依赖 pom.xml <!--shiro--> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring-boot-web-starter</artifactId 阅读全文 »
posted @ 2020-12-02 15:51 zolmk 阅读(145) 评论(0) 推荐(0) 编辑
摘要:Spring Boot Security 使用注解进行权限控制 注:如 @RolesAllowed({"ADMIN"}) ,则所对应的权限为 ROLE_ADMIN,如果权限为 ADMIN,则会报无权限错误!!!!! 阅读全文 »
posted @ 2020-12-02 15:49 zolmk 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Spring Security 配合 Thymeleaf 使用 注:Thymeleaf H5标注头: xmlns:th="https://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security" 且 阅读全文 »
posted @ 2020-12-02 15:48 zolmk 阅读(107) 评论(0) 推荐(0) 编辑
摘要:Spring Security 配置 参考 https://docs.spring.io/spring-security/site/docs/5.4.1/guides/#hello-world 1、首先在 pom.xml 文件中添加 Spring Security <dependency> <gro 阅读全文 »
posted @ 2020-12-02 15:47 zolmk 阅读(87) 评论(0) 推荐(0) 编辑
摘要:Spring Boot Cache 一、Spring 缓存抽象 Spring 从 3.1 开始定义了 org.springframework.cache.Cache 和 org.springframework.cache.CacheManager 接口来统一不同的缓存技术;并支持使用 JCache( 阅读全文 »
posted @ 2020-12-02 15:46 zolmk 阅读(194) 评论(0) 推荐(0) 编辑
摘要:Spring Boot 自定义 starters starter: 这个场景需要用到的依赖是什么 如何编写自动配置 @Configuration // 指明这个类为自动配置类 @ConditionalOnXXX // 在指定条件成立的情况下自动配置类生效 @AutoConfigureAfter // 阅读全文 »
posted @ 2020-12-02 15:44 zolmk 阅读(66) 评论(0) 推荐(0) 编辑
摘要:Spring Boot 与消息 一、概述 两个重要概念:消息代理和目的地,当消息发送者发送消息以后,将由消息代理接管,消息代理保证消息传递到指定目的地。 消息队列主要有两种形式的目的地 队列(queue):点对点消息通信 主题(topic):发布、订阅消息通信 点对点式: 消息发送者发送消息,消息代 阅读全文 »
posted @ 2020-12-02 15:41 zolmk 阅读(84) 评论(0) 推荐(0) 编辑
摘要:Spring Boot 微服务 微服务指提供一个或多个 Rest 接口的小 Spring Boot 项目,创建过程和一般 Spring Boot 项目相同 一、使用 Spring Boot Actuator 来监视 Spring Boot 项目 在创建初始化项目中,在 Ops 下选择 Spring 阅读全文 »
posted @ 2020-12-02 15:37 zolmk 阅读(115) 评论(0) 推荐(0) 编辑
摘要:Spring 中 @Component 和 @Bean 的区别 1、@Component 注解 告诉 Spring 当前类是一个组件,在扫描时应该将它当成一个 Bean,装配到容器中 是一个类注解 2、@Bean 注解 告诉 Spring 当前方法的返回值是一个 Bean 是方法注解 相对而言 @B 阅读全文 »
posted @ 2020-12-02 15:36 zolmk 阅读(109) 评论(0) 推荐(0) 编辑
摘要:RabbitMQ安装步骤 1、去 docker Hub 上查找相关镜像(选择带management的镜像,提供 web 管理界面) 2、拉取镜像 docker pull rabbitmq:3.8.9-management 3、启动 RabbitMQ docker run -d -p 5672:567 阅读全文 »
posted @ 2020-12-02 15:35 zolmk 阅读(65) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示