随笔 - 44  文章 - 3  评论 - 4  阅读 - 94228 

随笔分类 -  spring boot

springSecurity 在子线程中无法获取到用户信息
摘要:原因: 因为用户信息存储在threadLocal中 ,所以在子线程中无法获取 SecurityContextHolder 中有三种存储策略 public static final String MODE_THREADLOCAL = "MODE_THREADLOCAL"; public static 阅读全文
posted @ 2023-02-02 11:16 JonRain0625 阅读(798) 评论(0) 推荐(0) 编辑
springboot-MVC 过滤器使用
摘要:一、前言 一下代码以SSO用户登录列子代码。完整代码https://gitee.com/xuxueli0323/xxl-sso 二、使用 2.1 创建过滤器 创建一个过滤器,实现Filter 接口 public class XxlSsoTokenFilter extends HttpServlet 阅读全文
posted @ 2021-04-23 22:04 JonRain0625 阅读(511) 评论(0) 推荐(0) 编辑
springboot 设置项目路劲后不能访问首页
摘要:环境背景 学习版本 : springboot2.31 controller 代码 @controller public class Iindex{ @RequestMapping(“/”) public String index(){ return “/index” } } 开始没有设置 serve 阅读全文
posted @ 2020-07-18 00:44 JonRain0625 阅读(541) 评论(0) 推荐(0) 编辑
Spring 的 init-method 和 destory-method
摘要:关于在spring 容器初始化 bean 和销毁前所做的操作定义方式有三种 第一种注解: 通过@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作 第二种是XML配置: 通过 在xml中定义init-method 和 destory-method方法 阅读全文
posted @ 2020-03-22 21:41 JonRain0625 阅读(1552) 评论(0) 推荐(0) 编辑
Spring boot 配置文件默认放置位置,和加载优先级
摘要:一 、默认配置文件目录 spring boot 启动会扫描以下位置的application.properties 或者application.yml文件作为spring boot 的默认配置文件 ,加载的优先由上到下,加载的时候,会把以下路劲的文件都加载一遍。不同的配置内容会全部加载到系统,对于重复 阅读全文
posted @ 2019-09-05 00:31 JonRain0625 阅读(7451) 评论(0) 推荐(0) 编辑
spring boot 配置属性值获取注解@Value和@ConfigurationProperties比较
摘要:功能比较 : @ConfigurationProperties @Value 映射赋值 批量注入配置文件中的属性 一个个指定 松散绑定(松散语法)① 支持 不支持 SpEL② 不支持 支持 JSR303数据校验③ 支持 不支持 复杂类型封装④ 支持 支持 说明 ① 指属性在配置文件中value是否对 阅读全文
posted @ 2019-08-10 08:01 JonRain0625 阅读(1101) 评论(0) 推荐(0) 编辑
yaml 配置文件的语法。
摘要:1、基本语法 1. k:(空格)v:表示一对键值对(注意:空格必须有); 2.以**空格**的缩进来控制层级关系;只要是左对齐的一列数据,都是同一个层级的 3.值的驼峰写法和用“-”隔开是一样的值,如:lastName 和 last-name 都是可以的 4.列子: server: port: 80 阅读全文
posted @ 2019-08-09 14:01 JonRain0625 阅读(1750) 评论(0) 推荐(0) 编辑
Spring boot 数据源配置。
摘要:配置文件 : spring boot 配置文件 有两种形式 ,一种是properties文件、一种是yml文件。案列使用properties文件。 数据源的默认配置 : spring boot 约定优先于配置 ,所以数据源也有默认的配置,所有的默认配置文件基本都已xxxautoConfigurati 阅读全文
posted @ 2019-08-06 22:47 JonRain0625 阅读(1274) 评论(0) 推荐(0) 编辑
spring boot @EnableWebMvc禁用springMvc自动配置原理。
摘要:说明: 在spring boot中如果定义了自己的java配置文件,并且在文件上使用了@EnableWebMvc 注解,那么sprig boot 的默认配置就会失效。如默认的静态文件配置路径:"classpath:/META-INF/resources/", "classpath:/resource 阅读全文
posted @ 2019-08-04 23:37 JonRain0625 阅读(2802) 评论(0) 推荐(0) 编辑
spring boot springMVC扩展配置 。WebMvcConfigurer ,WebMvcConfigurerAdapter
摘要:摘要: 在spring boot中 MVC这部分也有默认自动配置,也就是说我们不用做任何配置,那么也是OK的,这个配置类就是 WebMvcAutoConfiguration,但是也时候我们想设置自己的springMvc配置怎么办呢 。我们也可以写个自己的配置类,继承 WebMvcConfigurer 阅读全文
posted @ 2019-08-04 21:20 JonRain0625 阅读(1770) 评论(0) 推荐(0) 编辑
springMVC WebApplicationInitializer 替代web.xml 配置Servlet 之原理
摘要:Servlet 3.0之前 ,xml 配置 在过去搭建spring + springMCV ,首先第一步要做的是什么 ,就是要配置web.xml 文件 ,把springMVC 中的Servlet 加载到tomcat 。通过加载 dispatcher 来启动整个spring容器。web.xml 如下 阅读全文
posted @ 2019-08-03 01:36 JonRain0625 阅读(1352) 评论(0) 推荐(0) 编辑
spring Profile 为不同环境提供不同的配置支持
摘要:说明 Profile为在不同环境下使用不同的配置提供了支持(开发环境下的配置和生产环境下的配置肯定是不同的, 例如, 数据库的配置) 。 在spring开发中用@Profile 注解使用来选择行配置系统属性。而在spring boot 中使用跟方便。 传统的spring Profile使用 参考《j 阅读全文
posted @ 2019-08-01 21:29 JonRain0625 阅读(254) 评论(0) 推荐(0) 编辑
Springboot(1) helloworld 搭建环境
摘要:一 、springboot 运行环境: 1. jdk1.8:Spring Boot 推荐jdk1.7及以上;java version "1.8.0_112" 2.–maven3.x:maven 3.3以上版本;Apache Maven 3.3.9 找到maven的setting 文件 ,路径: ap 阅读全文
posted @ 2019-07-27 22:36 JonRain0625 阅读(226) 评论(0) 推荐(0) 编辑

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