随笔分类 - Springboot
摘要:JAVA byte[]转String 中文问题 public static void main(String[] args) { String str1 = "123456中国"; byte[] src = str1.getBytes(); Charset charset = Charset.def
阅读全文
摘要:结合SpringBoot的策略模式套路,代码少些if-else 1、编写接口 /** * 计算策略接口 * @author xuchen * @Date: 2021/3/8 19:07 */ public interface CalculateStrategy { int doOperation(i
阅读全文
摘要:@NonNull : 注解在参数上, 如果该类参数为 null , 就会报出异常, throw new NullPointException(参数名) @Cleanup : 注释在引用变量前, 自动回收资源 默认调用 close() 方法 @Getter/@Setter : 注解在类上, 为类提供读
阅读全文
摘要:注解@JsonFormat主要是后台到前台的时间格式的转换 注解@DataFormAT主要是前后到后台的时间格式的转换 注解@JsonFormat <!--JsonFormat--> <dependency> <groupId>com.fasterxml.jackson.core</groupId>
阅读全文
摘要:一、添加依赖在pom.xml文件中 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> 二、实体类
阅读全文
摘要:1、pom.xml文件中添加 <!-- 热部署开发工具 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> 2
阅读全文
摘要:1. 先在pom.xml中添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> 2. 所有的监
阅读全文
摘要:1、pom.xml文件中加入 <dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>2.1.1</version> <
阅读全文
摘要:后端把Long类型的数据传给前端,前端可能会出现精度丢失的情况 方法一:在后台将这个Long类型的字段转换成String类型的。 方法二:使用fastjson的提供的注解,@JSONField(serializeUsing= ToStringSerializer.class)。 比如数据表字段为数字
阅读全文
摘要:项目中引用了mongo驱动 <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>1.9.0.RELEASE</version><!
阅读全文
摘要:1. 执行命令 —— Java jar demo.jar 1)可以在 当前Jar文件目录 建 config同级目录,这个config同级目录放入 application.yml 2) 也可以在 当前Jar文件目录 直接放入application.yml 2. 执行命令 —— java -jar de
阅读全文
摘要:Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。 作用: 接口的文档在线自动生成。 功能测试。 1、配置pom.xml <!-- swagger --> <dependency> <
阅读全文
摘要:1、pom配置 2、启动类上加注解:@EnableScheduling 3、创建定时任务实现类 4、参数说明: @Scheduled接受两种定时的设置: 一种是cornexpression。 一种是Rate/Delay表达式(毫秒值): @Scheduled(fixedRate = 6000):上一
阅读全文

浙公网安备 33010602011771号