随笔分类 - SpringBoot
摘要:1.解决方案 management: #关闭http监控端点: actuator无法访问 server: port: -1 #关闭监控端点: health,info等端点404 endpoints: enabled-by-default: false
阅读全文
摘要:1. 问题现象 接口返回的字符串首尾多了双引号 2. 解决方案 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Bean public StringHttpMessageConver
阅读全文
摘要:1. 问题原因 RestTemplate的构造器创建了一个默认字符集为ISO-8859-1的StringHttpMessageConverter对象, 它的默认编码格式为ISO-8859-1, 所以需要修改这个StringHttpMessageConverter对象的编码格式即可 2. 解决方案 @
阅读全文
摘要:###1. 代码配置 @Data @Configuration public class BeanConfig { @Value("${restTemplate.connectTimeout}") private Integer connectTimeout; @Value("${restTempl
阅读全文
摘要:##1. mavne依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> ##2.Aop ###2.1 As
阅读全文
摘要:1. 问题现象 spring boot 项目中,Tomcat 接收到 content-type 为 multipart/form-data 的请求时,需要将接收的文件缓存到临时目录(默认下载 /tmp 目录下); 如果 临时文件目录被删除,则会引发异常: Failed to parse multip
阅读全文
摘要:【参考文章】:Spring boot开启Gzip压缩 【参考文章】:Accept-Encoding Spring 版本 :5.1.2-RELEASE 1. application.yml 配置 2. gzip gzip是一种编码格式; 它是在一个文本文件中找出类似的字符串, 并临时替换他们,使整个文
阅读全文
摘要:###1. pom 添加jackjson相关依赖前, 先看下当前的pom中是否有其他依赖已经引入了jackjson 如果没有, 直接手动引入jackjson的依赖,保持版本一致 如果已经引入了一部分或者全部, 则调整依赖版本一致 <dependency> <groupId>org.springfra
阅读全文
摘要:【参考文章】:Required MultipartFile parameter 'file' is not present 【参考文章】:Springboot2.0中WebMvcConfigurerAdapter过时问题处理 【参考文章】:spring boot EnableAutoConfigur
阅读全文
摘要:【参考文章】:SpringBoot之@EnableConfigurationProperties分析 【参考文章】:在Spring Boot中使用 @ConfigurationProperties 注解, @EnableConfigurationProperties 1. pom 2. main方法
阅读全文
摘要:1. 未设置 getter(),setter()方法,导致属性值注入失败; 2. spring 未扫描到该组件,在其他类中注入该对象失败,可在配置类添加 @configuration 或者 @component 注解解决; 3. 在主类添加 @EnableConfigurationPropertie
阅读全文
摘要:1. thymeleaf 配置参数 【参考文章】:spring-boot-starter-thymeleaf 避坑指南
阅读全文
摘要:1. 项目结构 2. pom文件配置 重点是红色框内的依赖 3. application配置文件 4. controller 注意使用@Controller注解; @RestController 等价于 @Controller 加上 @ResponseBody. 如果使用@RestControlle
阅读全文
摘要:【传送门】:详解WebMvcConfigurer接口 1. 设置跨域规则
阅读全文