随笔分类 -  springboot

springboot中用@FeignClient 调用第三方服务,自定义设置Header
摘要:问题描述 在springboot项目中集成Feign访问第三方服务时,需要在header中设置token,具体操作步骤如下。 在使用@FeignClient之前需要引入的包: <!-- spring cloud --> <dependency> <groupId>org.springframewor 阅读全文
posted @ 2021-06-09 18:45 乡野少年 阅读(6710) 评论(0) 推荐(1)
SpringBoot中使用ContextLoader.getCurrentWebApplicationContext() 获取WebApplicationContext为null的问题
摘要:获取不到的原因:springboot无论以main方法还是spring-boot:run的方式执行都不会跑SpringBootServletInitializer中的onStartup导致ContextLoaderListener没有执行。 考虑到以往的经验ContextLoaderListener 阅读全文
posted @ 2021-06-08 18:02 乡野少年 阅读(3196) 评论(0) 推荐(0)
SpringBoot 获取上下文,获取bean的几种中方式
摘要:传统Spring项目 在写传统的spring项目中,一般通过初始化抽象类AbstractXmlApplicationContext 的实现类,并传入spring.xml,来获取应用上下文,最终通过getBean方法获取bean,如下: ApplicationContext app1 = new Fi 阅读全文
posted @ 2021-06-08 17:43 乡野少年 阅读(19918) 评论(0) 推荐(1)
Property 'spring.profiles.active' imported from location 'class path resource [application-xx.yml]' is invalid in a profile specific resource [origin: class path resource [application-xx.yml] ]问题排查和修复
摘要:问题描述 最近用springboot写后端服务,之前明明可以运行的多环境配置,突然不奏效了,报如下错误: org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.prof 阅读全文
posted @ 2021-05-24 17:16 乡野少年 阅读(18621) 评论(0) 推荐(0)
spring 中 的 AbstractApplicationContext.refresh()方法源码解析
摘要:话不多说直接上代码 @Override public void refresh() throws BeansException, IllegalStateException { synchronized (this.startupShutdownMonitor) { StartupStep cont 阅读全文
posted @ 2021-05-18 18:11 乡野少年 阅读(137) 评论(0) 推荐(0)
springboot启动报错:Handler dispatch failed; nested exception is java.lang.AbstractMethodError
摘要:最近在用springboot构建项目,控制台报错:Handler dispatch failed; nested exception is java.lang.AbstractMethodError,看了下代码编译,bean依赖,jar包版本,网上找了好多资料,依然没发现问题。 最后终于解决。 原因 阅读全文
posted @ 2020-04-17 16:31 乡野少年 阅读(16786) 评论(0) 推荐(0)