随笔分类 -  spring & springboot / cloud

摘要:参考信息 本人参考的是这一篇,描述方面比本人好得多: springboot线程池的使用和扩展 VisiableThreadPoolTaskExecutor 背景: 简略记一下,笔记: 目标是想在 springboot服务下,自定义一个线程池,然后使用异步,原目的是为了批量导入用。 项目架构 普通的s 阅读全文
posted @ 2022-12-07 20:47 aaacarrot 阅读(2280) 评论(0) 推荐(0)
摘要:背景 1、使用 Squaretest 生成controller的测试类(略) 生成的代码大概如下: 该文章只简单记录使用的一个过程,和遇到过的一个小问题, 就是,requestbody 传参无效 import com.alibaba.fastjson.JSON; import org.junit.T 阅读全文
posted @ 2022-12-06 17:26 aaacarrot 阅读(227) 评论(0) 推荐(0)
摘要:简单记录一下关于对于数据校验的方式,和对应包的引入 1、controller层的参数要加上 @Validated 2、对应参数对象的属性,就用 @NotNull 等注解。 controller 层 定义方法: import org.springframework.validation.annotat 阅读全文
posted @ 2022-12-06 17:12 aaacarrot 阅读(208) 评论(0) 推荐(0)
摘要:该文档主要描述,在 springboot项目下相关的一些配置项的使用记录及说明 1、日志文件配置项 对应的配置项就是: logging.file = ./logs/xxx.log 表示这个服务的日志要输出到当前目录的 logs下的 xxx.log 文件。 项目进程之前启动,直接使用 nohup 输出 阅读全文
posted @ 2022-11-18 14:23 aaacarrot 阅读(54) 评论(0) 推荐(0)
摘要:1、@ConfigurationProperties 与 @Value 区别 (1)@Value 要写全路径 (2)@ConfigurationProperties 用了这个,并且指定 prefix, 那它的属性就能自动匹配了,不用再写 @Value 了 (3)@ConfigurationPrope 阅读全文
posted @ 2022-09-08 14:40 aaacarrot 阅读(37) 评论(0) 推荐(0)
摘要:关于springboot服务使用配置中心后,配置项的优先级问题 springboot的配置优先级 命令行参数 > 操作系统环境变量 > 应用外的配置文件 > 应用内的配置文件 这里命令行参数设置的优先级是最高的,方便部署不同环境。 加入springcloud配置中心后 加入springcloud的配 阅读全文
posted @ 2022-08-25 17:10 aaacarrot 阅读(2041) 评论(0) 推荐(0)
摘要:今天在页面上做一个文件上传,之前上传的文件相对较小,基本不会超过10M,一直也运行得挺好。今天要上传一个功能,大小大概是80M左右,然后在页面的文件上传请求,一直在pending,然后过了大概一两分钟,页面还在转,看接口,是显示:"this request has no response data 阅读全文
posted @ 2022-07-11 20:35 aaacarrot 阅读(800) 评论(0) 推荐(0)
摘要:yml 配置数组 project.tools:[ ' aa ',' bb ',' cc ' ] 或 project.tools: - aa - bb - cc @Value 对复杂对象解析不好,复杂对象要用类去配置接收。(好像也和 springboot 版本有关系。 比如某个属性 以下方法貌似是不行 阅读全文
posted @ 2022-06-09 17:36 aaacarrot 阅读(849) 评论(0) 推荐(0)
摘要:1、@Autowired 默认是使用类型去识别 @Resource 默认使用beanName 去匹配, 也可以使用bean类型去。。。 阅读全文
posted @ 2022-05-31 09:45 aaacarrot 阅读(36) 评论(0) 推荐(0)
摘要:背景 1、使用feign调用第三方接口,响应的数据结构不太规范,也很容易返回500,即使是参数错误也是返回500的,所以必须要捕获异常 2、开始时,使用 catch BusinessException (BusinessException是封装的异常类,extend RuntimeException 阅读全文
posted @ 2022-05-24 09:58 aaacarrot 阅读(1542) 评论(0) 推荐(0)
摘要:EUREKA客户端怎样配置 相关版本 springboot 版本:2.1.17 (貌似 springboot1.x 和 2.x 有一点区别) 步骤 1、添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId 阅读全文
posted @ 2022-05-23 21:11 aaacarrot 阅读(45) 评论(0) 推荐(0)
摘要:背景: 起了一个 springboot 服务,在bootstrap.yml 文件中配置了配置中心的文件,但服务启动的时候,没有读取去读取配置中心 1、没有添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactI 阅读全文
posted @ 2022-05-22 12:37 aaacarrot 阅读(198) 评论(0) 推荐(0)
摘要:背景: 1、已经安装好 zipkin 步骤 1、pom.xml添加相关的依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> 阅读全文
posted @ 2022-05-12 21:08 aaacarrot 阅读(416) 评论(0) 推荐(0)
摘要:背景: 1、zipkin的首页:https://zipkin.io/pages/quickstart.html 支持docker, jar, 服务启动 https://www.jianshu.com/p/032126851bb7 2、下载到jar后 启动脚本:后台启动:nohup java -jar 阅读全文
posted @ 2022-05-12 20:00 aaacarrot 阅读(1108) 评论(0) 推荐(0)
摘要:@RequestParam,@PathParam,@PathVariable等注解区别 @RequestMapping("/hello/{id}") public String getDetails(@PathVariable(value="id") String id, @RequestParam 阅读全文
posted @ 2022-05-11 19:01 aaacarrot 阅读(25) 评论(0) 推荐(0)
摘要:背景: 开发环境,发现某接口时好时坏,看了一个eureka,发现是同一个服务,被2个地方注册上来了,根据网关路由,其中有一个是开发环境的同学也用了相同的名字注册上来了,关键是这个开发同学的服务还调不通。emmm,想把它给停掉,but, eureka好像没有主动让服务下线的方法?即使有,好像也不是特别 阅读全文
posted @ 2022-04-18 20:17 aaacarrot 阅读(279) 评论(0) 推荐(0)
摘要:给网关做一个拦截 import com.netflix.zuul.ZuulFilter; import com.netflix.zuul.context.RequestContext; import org.springframework.cloud.netflix.zuul.filters.sup 阅读全文
posted @ 2022-04-14 17:35 aaacarrot 阅读(45) 评论(0) 推荐(0)
摘要:1、No MyBatis mapper was found in '[com.hxf.fastmybatis.mapper]' package. Please check your configuration 2、Public Key Retrieval is not allowed 在我们使用My 阅读全文
posted @ 2022-04-09 22:02 aaacarrot 阅读(220) 评论(0) 推荐(0)
摘要:1、启动时,说找不到bean (即某个 bean 没有被加到 容器中进行管理) 情况1:这个类没有被扫描到,得看下,启动或配置类上,有没有扫描到这个类所在的目录下,如果是 feign 的话,就在启动类看一下有没有添加这个注解, @EnableFeignClients , 如果有添加注解,还得这个注解 阅读全文
posted @ 2022-04-04 10:37 aaacarrot 阅读(271) 评论(0) 推荐(0)
摘要:从spring容器中获取bean的方式 1、通过applicationContext 中获得。但这个 application要在启动类里面,把它给 set进来, 不然这个 applicationContext 首先是拿不到的 (这种写法用于,写了一个类,里面要用到spring容器管理的bean,但这 阅读全文
posted @ 2022-03-11 13:59 aaacarrot 阅读(951) 评论(0) 推荐(0)