Lombok

Java14来了!Switch竟如此简单?Lombok也不需要了?来用Idea搭建Java14吧!

放肆的年华 提交于 2020-03-22 18:19:23
3 月,跳不动了?>>> Java 14 在 2020.3.17 日发布正式版了,但现在很多公司还在使用 Java 7 或 Java 8,每当看到 Java 又发布新版本心里就慌得一匹。不过此版本并不是 LTS (长期支持版) 版本,所以不要慌,我们先来了解一下好了,等 LTS 版本发布后再用也不迟。 版本说明 现在 Java 的发布节奏是每年发布两个 GA (General Availability,正式发布版),每 6 个月发布一版,发布月份为 3 月和 9月。 Oracle 只对 LTS 版本提供付费支持,其中包括 Java 8 和 Java 11,Java 11 的付费支持会持续到 2026 年,每 3 年发布一个 LTS 版,下一个 LTS 版本将是 Java 17。 Java 版本的快速更新,一定程度上是为了迎合了开发者和现在技术发展的潮流,同时也利于 Java 版本的交付,把大版本拆成小版本,起码不会出现大的延期了。 Java 14 新特性 此版本包含的 JEP (Java/JDK Enhancement Proposals,JDK 增强提案) 比 Java 12 和 Java 13 加起来都多,总共 16 个新特性。 305: instanceof 的模式匹配 (预览) 343: 打包工具 (Incubator) 345: G1 的 NUMA 内存分配优化 349:

启动崩盘!IDEA 2020 无法启动的解决办法|赠送 IDEA 2020 新功能

时间秒杀一切 提交于 2020-03-22 15:16:25
3 月,跳不动了?>>> 今天早上看到 IDEA 可以升级新版本,想着体验一下新功能,点击升级,然后全部项目工程无法打开。 报错信息如下: Cannot execute command No project found to open file in 在项目窗口选择项目工程也不行,出现 闪退 现象。 网上搜索了一把,没有找到具体的解决办法,没办法只能靠自己。 突然想到可以看一下 IDEA 相关日志,看下是否有什么有用的报错信息。 如果使用 toolbox 可以在 IDEA 设置中,找到如下按钮快速打开。 若没有安装 toolbox,可以在下面路径找到: // macos IDEA-XX 代表你要查找 IDEA 具体版本,例如:~/Library/Logs/IntelliJIdea2019.3 ~/Library/Logs/<product><version> // windows 例如:C:\Users\JohnS\.IntelliJIdea2019.3\system\log %HOMEPATH%\.<product><version>\system\log 打开日志文件,显示一堆错误,最明显错误如下: 看到这里,初步怀疑 FindBugs-IDEA 暂不适配最新版本 IDEA,从而导致项目工程打不开。 另外切回窗口窗口如下位置,也能看到报错信息。 在插件管理处禁用该插件

文件上传和下载

梦想与她 提交于 2020-03-22 12:16:10
3 月,跳不动了?>>> 用于存储文件信息的表名 CREATE TABLE `visit_file` ( `id` varchar(32) COLLATE utf8_bin NOT NULL, `visit_id` varchar(32) COLLATE utf8_bin NOT NULL, `file_name` varchar(200) COLLATE utf8_bin NOT NULL, `file_new_name` varchar(200) COLLATE utf8_bin NOT NULL, `save_path` varchar(200) COLLATE utf8_bin NOT NULL, `file_suffix` varchar(10) COLLATE utf8_bin NOT NULL, `file_size` varchar(200) COLLATE utf8_bin NOT NULL, `fcd` date NOT NULL, `fcu` varchar(10) COLLATE utf8_bin NOT NULL, `lcd` date NOT NULL, `lcu` varchar(10) COLLATE utf8_bin NOT NULL, `is_del` varchar(2) COLLATE utf8_bin NOT NULL, PRIMARY

微服务系列之 Consul 服务注册中心

假如想象 提交于 2020-03-20 11:52:42
3 月,跳不动了?>>> 原文链接: https://mrhelloworld.com/posts/spring/spring-cloud/consul-service-registry/   Netflix Eureka 2.X https://github.com/Netflix/eureka/wiki 官方宣告停止开发,但其实对国内的用户影响甚小,一方面国内大都使用的是 Eureka 1.X 系列,并且官方也在积极维护 1.X https://github.com/Netflix/eureka/releases。 The existing open source work on eureka 2.0 is discontinued. The code base and artifacts that were released as part of the existing repository of work on the 2.x branch is considered use at your own risk. Eureka 1.x is a core part of Netflix's service discovery system and is still an active project. 翻译: 有关 eureka 2.0 的现有开源工作已停止。在 2.x

获取接口所有子类和获取枚举扩展属性

陌路散爱 提交于 2020-03-20 05:52:04
3 月,跳不动了?>>> 问题: 如何根据接口获取所有子类/实现类 获取枚举的所有值 反射获取扩展属性 处理 引入 reflections 类库 <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version>0.9.12</version> </dependency> 枚举接口定义 public interface IEnum<T extends Enum> { int getCode(); String getDesc(); String getName(); IEnum[] enumValues(); } import lombok.Builder; import lombok.Data; @Data @Builder public class EnumItem { String name; int code; String desc; } 遍历所有实现类,放入枚举Map Reflections reflections = new Reflections("com.demo.common.consts.enums"); Set<Class<? extends IEnum>> items = reflections.getSubTypesOf(IEnum

我的IDEA插件

霸气de小男生 提交于 2020-03-19 17:53:56
3 月,跳不动了?>>> 规约:Alibaba Java Coding Guidelines 好看的背景图: Background Image Plus 热部署:Jrebel 快捷键提示: Key Promoter X 不用写set、get:Lombok 括号:Rainbow Brackets Restful测试接口:RestfulToolkit 代码统计:Statistic 翻译:Translation 我的主题是:Xcode-Dark Theme 特效编码:Power Mode ll Maven文件:Maven Helper 颜色Console:Grep Console 来源: oschina 链接: https://my.oschina.net/u/3358860/blog/3198289

0318 guava并发工具

安稳与你 提交于 2020-03-19 13:57:20
3 月,跳不动了?>>> <br /> <br />并发是一个难题,但是可以通过使用强力简单的抽象来显著的简化,为了简化问题,guava扩展了Future接口,即 ListenableFuture (可以监听的Future)。<br />我强烈建议你在你的所有代码里使用ListenableFuture去替代Future,原因如下: 很多的Futures 类的方法需要它。(Futures工具类使用) 它比后来改造为ListenableFutrue更简单。(早点使用比重构更简单) 工具方法的提供者不需要提供Future和ListenableFuture方法的变体。(不需要兼容两套) <br /> 接口 一个传统的Futrue代表一个异步计算的结果:一个可能完成也可能没有完成输出结果的计算。<br />一个Future可以用在进度计算,或者说是 一个提供给我们结果的服务的承诺。<br /> <br />一个ListenableFuture允许注册当你在计算完成的时候的回调,或者计算已经完成了。<br />这个简单的增强让高效支持多种操作成为可能。而Future接口并不能支持。<br /> <br />ListenbleFuture中添加的基本操作是<br />addListener(Runnable , Executor ),<br />它指出了当未来计算完成时

How to specify the order of parameters in @AllArgsConstructor in lombok

时光怂恿深爱的人放手 提交于 2020-03-18 03:42:40
问题 If I have a class like below, import lombok.AllArgsConstructor; @AllArgsConstructor class MyClass{ private String one; private Integer three; private Integer two; } What will be the order of parameters in the generated constructor ? Is it always like below, public MyClass(String one, Integer three, Integer two) { this.one = one; this.three = three; this.two = two; } I noticed it's the order of declaration in the class itself. But need to confirm it. Couldn't find any documentation that verify

How to specify the order of parameters in @AllArgsConstructor in lombok

本小妞迷上赌 提交于 2020-03-18 03:42:33
问题 If I have a class like below, import lombok.AllArgsConstructor; @AllArgsConstructor class MyClass{ private String one; private Integer three; private Integer two; } What will be the order of parameters in the generated constructor ? Is it always like below, public MyClass(String one, Integer three, Integer two) { this.one = one; this.three = three; this.two = two; } I noticed it's the order of declaration in the class itself. But need to confirm it. Couldn't find any documentation that verify

Spring Boot logging with Lombok

谁说胖子不能爱 提交于 2020-03-17 04:47:07
问题 I would like to use Project Lombok's log annotation in my Spring Boot projects but I don't want to lose the functionality of being able to change the logging from the application.properties . The Spring logging docs aren't overly clear on what the default logging implementation should be used, and there are 7 Lombok choices! Any ideas? 回答1: I would use @Slf4j. Tested the following and it works as expected. @SpringBootApplication @Slf4j public class DemoApplication { public static void main