{"id":1494,"date":"2023-03-25T13:44:47","date_gmt":"2023-03-25T05:44:47","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1494"},"modified":"2023-04-28T20:29:05","modified_gmt":"2023-04-28T12:29:05","slug":"lombok-builder-constructor-default-value-invalid","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/lombok-builder-constructor-default-value-invalid\/","title":{"rendered":"Lombok Builder\u6784\u9020\u5668\u9ed8\u8ba4\u503c\u5931\u6548"},"content":{"rendered":"<blockquote>\n<p><code>1.16.*<\/code>\u53ca\u4ee5\u4e0b\u7248\u672c\uff1a<code>@Data<\/code>\u9ed8\u8ba4\u4f1a\u751f\u6210<code>private<\/code>\u7684\u65e0\u53c2\u6784\u9020\u51fd\u6570\uff0c<code>Builder<\/code>\u9ed8\u8ba4\u503c\u4e0d\u751f\u6548\uff0c\u4f46\u662fnew\u7684\u5bf9\u8c61\u9ed8\u8ba4\u503c\u751f\u6548<br \/>\n<code>1.18.*<\/code>\u53ca\u4ee5\u4e0a\u7248\u672c\uff1a<code>@Data<\/code>\u9ed8\u8ba4\u4e0d\u4f1a\u751f\u6210\u65e0\u53c2\u6784\u9020\u51fd\u6570\uff0c<code>Builder<\/code>\u9ed8\u8ba4\u503c\u751f\u6548\uff0c\u4f46\u662fnew\u7684\u5bf9\u8c61\u9ed8\u8ba4\u503c\u4e0d\u751f\u6548<\/p>\n<\/blockquote>\n<p><!-- more --><\/p>\n<pre><code class=\"language-java\">public class Test {\n\n    public static void main(String[] args) throws Exception {\n        User user = User.builder().build();\n        System.out.println(&quot;name: &quot; + user.getName());\n        System.out.println(&quot;age: &quot; + user.getAge());\n        System.out.println(&quot;isVip: &quot; + user.isVip());\n    }\n\n    @Data\n    @Builder\n    static class User {\n        private String name = &quot;Joe.Ye&quot;;\n        private int age = 20;\n        private boolean isVip = true;\n    }\n}<\/code><\/pre>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<pre><code>name: null\nage: 0\nisVip: false<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1.16.*\u53ca\u4ee5\u4e0b\u7248\u672c\uff1a@Data\u9ed8\u8ba4\u4f1a\u751f\u6210private\u7684\u65e0\u53c2\u6784\u9020\u51fd\u6570\uff0cBuilder\u9ed8\u8ba4\u503c\u4e0d\u751f\u6548\uff0c\u4f46\u662fne [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[193],"class_list":["post-1494","post","type-post","status-publish","format-standard","hentry","category-java-basic","tag-lombok"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1494"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1494\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}