随笔分类 -  java

摘要:import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; 阅读全文
posted @ 2023-05-23 14:25 紫枫夜羽 阅读(112) 评论(0) 推荐(0) 编辑
摘要:方式一: @Component public class CommonUtils { private static SwitchConfig switchConfig; @Autowired public void setSwitchConfig(SwitchConfig switchConfig) 阅读全文
posted @ 2022-06-10 16:22 紫枫夜羽 阅读(3253) 评论(0) 推荐(0) 编辑
摘要:Java 中的 BigDecimal,80% 的人竟然都用错了。。。 点击关注 👉 Java核心技术 Java核心技术 微信号 java-core 功能介绍 专注分享Java核心技术干货,包括Java多线程、IO、JVM、Spring Boot、Spring Cloud、IntelliJ IDEA 阅读全文
posted @ 2022-05-31 15:10 紫枫夜羽 阅读(60) 评论(0) 推荐(0) 编辑
摘要:1. Stream 的distinct()方法 distinct()是Java 8 中 Stream 提供的方法,返回的是由该流中不同元素组成的流。distinct()使用 hashCode() 和 eqauls() 方法来获取不同的元素。 因此,需要去重的类必须实现 hashCode() 和 eq 阅读全文
posted @ 2022-04-28 15:46 紫枫夜羽 阅读(1412) 评论(0) 推荐(0) 编辑
摘要:@AllArgsConstructor替代@Autowired构造注入,多个bean 注入时更加清晰L @Slf4j @Configuration @AllArgsConstructor public class RouterFunctionConfiguration { private final 阅读全文
posted @ 2021-10-20 17:20 紫枫夜羽 阅读(53) 评论(0) 推荐(0) 编辑
摘要:1.导入pom依赖 <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> <version>3.2.0</version> </dependency> 阅读全文
posted @ 2021-07-14 09:06 紫枫夜羽 阅读(255) 评论(0) 推荐(0) 编辑
摘要:1. 通过Executors创建线程池的弊端 下面是创建定长线程池(FixedThreadPool)的一个例子,严格来说,当使用如下代码创建线程池时,是不符合编程规范的。 ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5 阅读全文
posted @ 2021-06-01 15:01 紫枫夜羽 阅读(79) 评论(0) 推荐(0) 编辑
摘要:1.分组通过groupingBy分组指定字段list.stream().collect(Collectors.groupingBy(User::getSex)); 2.过滤通过filter方法过滤某些条件list.stream().filter(a -> !a.getJobNumber().equa 阅读全文
posted @ 2020-05-27 15:16 紫枫夜羽 阅读(1626) 评论(0) 推荐(0) 编辑
摘要:public static void main(String[] args) { List<User> list = new ArrayList<>(); User u1 = new User("李四", "北京", 20); User u2 = new User("张三", "北京", 22); 阅读全文
posted @ 2020-05-27 15:13 紫枫夜羽 阅读(2215) 评论(0) 推荐(0) 编辑
摘要:public static void main(String[] args) { Map<String, Object> map = new HashMap<>(); map.put("1", "111"); map.put("2", "2222"); //1.需求:打印输出已经排好序的字符串数组中 阅读全文
posted @ 2019-10-14 17:32 紫枫夜羽 阅读(107) 评论(0) 推荐(0) 编辑
摘要:想验证前端传入对象的Integer属性 1.新建一个注解类 @FlagValidator import javax.validation.Constraint; import javax.validation.Payload; import java.lang.annotation.*; /** * 阅读全文
posted @ 2019-10-09 11:44 紫枫夜羽 阅读(352) 评论(0) 推荐(0) 编辑
摘要:public static boolean is2Power3(int num) { return (num & num - 1) == 0; } 阅读全文
posted @ 2019-09-09 15:43 紫枫夜羽 阅读(167) 评论(0) 推荐(0) 编辑
摘要:对象和字段自定义 /** * 判断List<Knowledge>的对象code是否有重复,有重复true * * @param orderList * @return */ private Boolean knowledgeIsRepeat(List<Knowledge> orderList) { 阅读全文
posted @ 2019-08-27 14:38 紫枫夜羽 阅读(12970) 评论(0) 推荐(0) 编辑
摘要:public static void main(String[] args) { List list = new ArrayList(); list.add(1); list.add(9); list.add(3); list.add(5); list.add(4); System.out.prin 阅读全文
posted @ 2019-08-15 15:06 紫枫夜羽 阅读(3378) 评论(0) 推荐(0) 编辑
摘要:public List<String> getDate (Date dBegin, Date dEnd) { List<String> dateList = new ArrayList(); dateList.add(DateUtil.formatDate(dBegin)); Calendar ca 阅读全文
posted @ 2019-08-15 10:50 紫枫夜羽 阅读(265) 评论(0) 推荐(0) 编辑
摘要:1.添加maven依赖 <!-- slf4j --><dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version></dependency><dependen 阅读全文
posted @ 2019-08-09 15:46 紫枫夜羽 阅读(284) 评论(0) 推荐(0) 编辑
摘要:引用https://segmentfault.com/a/1190000013654676 String formatted = String.format("%s今年%d岁。", "小李", 30); // "小李今年30岁。" 这个方法第一个参数是格式串,后面的参数都是格式串的参数,用于替换格式 阅读全文
posted @ 2019-08-09 09:39 紫枫夜羽 阅读(300) 评论(0) 推荐(0) 编辑
摘要:/** * 获得当月1号零时零分零秒 * @return */ public Date initDateByMonth(){ Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.set( 阅读全文
posted @ 2019-07-04 11:25 紫枫夜羽 阅读(1349) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/zzzgd_666/article/details/81671753 阅读全文
posted @ 2019-06-06 11:09 紫枫夜羽 阅读(194) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/sanyaoxu_2/article/details/80555328 阅读全文
posted @ 2019-06-06 11:07 紫枫夜羽 阅读(116) 评论(0) 推荐(0) 编辑