{"id":579,"date":"2026-09-21T18:27:29","date_gmt":"2026-09-21T10:27:29","guid":{"rendered":"https:\/\/www.kirasu.cn\/index.php\/2026\/09\/21\/%e8%af%be%e7%a8%8b-04-lombok%e4%b8%8e%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-2\/"},"modified":"2026-09-21T18:27:29","modified_gmt":"2026-09-21T10:27:29","slug":"%e8%af%be%e7%a8%8b-04-lombok%e4%b8%8e%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-2","status":"publish","type":"post","link":"https:\/\/www.kirasu.cn\/index.php\/2026\/09\/21\/%e8%af%be%e7%a8%8b-04-lombok%e4%b8%8e%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-2\/","title":{"rendered":"\u7b2c 4 \u8bfe Lombok + \u5f00\u53d1\u73af\u5883\u642d\u5efa"},"content":{"rendered":"<h1>\u7b2c 4 \u8bfe Lombok + \u5f00\u53d1\u73af\u5883\u642d\u5efa<\/h1>\n<blockquote>\n<p>\u672c\u8bfe\u4e24\u90e8\u5206\uff1a\u2460 \u8ba4\u8bc6 Lombok\u2014\u2014\u4e00\u4e2a\u5e2e\u4f60\u5c11\u5199\u300c\u6837\u677f\u4ee3\u7801\u300d\u7684\u5229\u5668\uff0c\u5b66\u5b8c\u80fd\u770b\u61c2\u9879\u76ee\u91cc 85 \u4e2a\u6587\u4ef6\u90fd\u5728\u7528\u7684\u6ce8\u89e3\uff1b\u2461 \u628a\u5f00\u53d1\u73af\u5883\uff08JDK 21 + IDEA + Lombok \u63d2\u4ef6 + Maven\uff09\u642d\u597d\u3001\u80fd\u81ea\u68c0\u3002\u5b66\u5b8c\u4f60\u5c31\u53ef\u4ee5\u771f\u6b63\u300c\u52a8\u624b\u8dd1\u9879\u76ee\u300d\u4e86\u3002<\/p>\n<\/blockquote>\n<hr \/>\n<h2>\u672c\u8bfe\u5b66\u4e60\u76ee\u6807<\/h2>\n<p>\u5b8c\u6210\u672c\u8bfe\u540e\uff0c\u4f60\u5c06\u80fd\u591f\uff1a<\/p>\n<ol>\n<li>\u7406\u89e3 Lombok \u7684\u539f\u7406\uff08\u7f16\u8bd1\u671f\u81ea\u52a8\u751f\u6210\u4ee3\u7801\uff09<\/li>\n<li>\u8ba4\u8bc6\u9879\u76ee\u5e38\u7528\u7684 6 \u4e2a Lombok \u6ce8\u89e3\uff0c\u5e76\u5728\u6e90\u7801\u4e2d\u627e\u5230\u771f\u5b9e\u7528\u4f8b<\/li>\n<li>\u5206\u6e05\u300c\u54ea\u4e9b\u7c7b\u7528 Lombok\u3001\u54ea\u4e9b\u4e0d\u7528\u300d\u2014\u2014\u5e76\u7ea0\u6b63\u4e00\u4e2a\u5e38\u89c1\u6587\u6863\u9519\u8bef<\/li>\n<li>\u642d\u597d\u5e76\u81ea\u68c0\u5f00\u53d1\u73af\u5883\uff1aJDK 21 \/ IDEA \/ Lombok \u63d2\u4ef6 \/ Maven<\/li>\n<li>\u4e86\u89e3 Git \u57fa\u7840\u5de5\u4f5c\u6d41<\/li>\n<\/ol>\n<hr \/>\n<h2>\u4e00\u3001\u77e5\u8bc6\u70b9\u8be6\u89e3<\/h2>\n<h3>1.1 Lombok \u662f\u4ec0\u4e48<\/h3>\n<p>Java \u7684\u300c\u6837\u677f\u4ee3\u7801\u300d\u5f88\u5570\u55e6\uff1a\u4e00\u4e2a\u5b9e\u4f53\u7c7b\u8981\u5199\u4e00\u5806 getter\/setter\u3001toString\u3001\u6784\u9020\u5668\u3002<strong>Lombok<\/strong> \u662f\u7f16\u8bd1\u671f\u6ce8\u89e3\u5904\u7406\u5668\u2014\u2014\u4f60\u5728\u7c7b\u4e0a\u5199 <code>@Data<\/code>\uff0c\u7f16\u8bd1\u65f6\u5b83<strong>\u81ea\u52a8\u5e2e\u4f60\u751f\u6210<\/strong>\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u6e90\u7801\u91cc\u5e72\u51c0\uff0c<code>.class<\/code> \u91cc\u65b9\u6cd5\u9f50\u5168\u3002<\/p>\n<ul>\n<li>\u4f9d\u8d56\u5df2\u7531\u6839 <code>pom.xml<\/code> \u7684 <code>&lt;dependencies&gt;<\/code> \u7edf\u4e00\u58f0\u660e\uff08\u7248\u672c\u7531 spring-boot-starter-parent \u7ba1\u7406\uff09\uff0c\u6240\u6709\u6a21\u5757\u90fd\u80fd\u7528\u3002<\/li>\n<li><strong>IDEA \u5fc5\u987b\u88c5 Lombok \u63d2\u4ef6<\/strong>\uff0c\u5426\u5219\u7f16\u8bd1\u62a5\u300ccannot find symbol \u65b9\u6cd5 getXxx()\u300d\u2014\u2014\u56e0\u4e3a IDEA \u9ed8\u8ba4\u4e0d\u8ba4\u8bc6\u8fd9\u4e9b\u81ea\u52a8\u751f\u6210\u7684\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<h3>1.2 \u9879\u76ee\u5e38\u7528\u7684 6 \u4e2a\u6ce8\u89e3\uff08\u771f\u5b9e\u7528\u4f8b\uff09<\/h3>\n<p>\u5168\u9879\u76ee\u5171 <strong>133 \u5904 \/ 85 \u4e2a\u6587\u4ef6<\/strong>\u7528\u5230 Lombok\uff0c\u5e38\u7528\u7684\u662f\u4e0b\u9762 6 \u4e2a\u3002<\/p>\n<h4>\u2460 <code>@Data<\/code> \u2014\u2014 \u4e00\u952e\u751f\u6210 Getter\/Setter\/ToString\/equals\/hashCode<\/h4>\n<p><strong>\u771f\u5b9e\u7528\u4f8b<\/strong> \u2014\u2014 <code>novel-front\/...\/vo\/BookVO.java<\/code>\uff08\u7b2c 13-14 \u884c\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">@Data\npublic class BookVO extends Book implements Serializable {\n    @JsonFormat(timezone = \"GMT+8\", pattern = \"MM\/dd HH:mm\")\n    private Date lastIndexUpdateTime;\n}<\/code><\/pre>\n<p><code>BookVO<\/code> \u7ee7\u627f\u4e86\u5b9e\u4f53 <code>Book<\/code>\uff0c\u81ea\u5df1\u53ea\u52a0\u4e86\u4e00\u4e2a\u5b57\u6bb5\u3002\u6ca1\u6709 Lombok \u7684\u8bdd\uff0c\u5b83\u8981\u590d\u5236 <code>Book<\/code> \u7684\u4e00\u5927\u5806 getter\/setter\uff0c\u8fd9\u91cc\u4e00\u884c <code>@Data<\/code> \u5168\u641e\u5b9a\u3002<\/p>\n<h4>\u2461 <code>@Slf4j<\/code> \u2014\u2014 \u76f4\u63a5\u83b7\u5f97\u65e5\u5fd7\u5bf9\u8c61 <code>log<\/code><\/h4>\n<p><strong>\u771f\u5b9e\u7528\u4f8b<\/strong> \u2014\u2014 <code>novel-front\/...\/FrontNovelApplication.java<\/code>\uff08\u7b2c 28-29 \u884c\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">@Slf4j\npublic class FrontNovelApplication {\n    \/\/ \u7f16\u8bd1\u540e\u81ea\u52a8\u751f\u6210 private static final Logger log = ...;\n    public static void main(String[] args) {\n        SpringApplication.run(FrontNovelApplication.class);\n        log.info(\"\u9879\u76ee\u542f\u52a8\u5566...\");   \/\/ \u76f4\u63a5\u7528 log\uff0c\u4e0d\u7528\u624b\u52a8 new Logger\n    }\n}<\/code><\/pre>\n<h4>\u2462 <code>@RequiredArgsConstructor<\/code> \u2014\u2014 \u4e3a final \u5b57\u6bb5\u751f\u6210\u6784\u9020\u5668\uff08\u914d\u5408\u6784\u9020\u5668\u6ce8\u5165\uff09<\/h4>\n<p><strong>\u771f\u5b9e\u7528\u4f8b<\/strong> \u2014\u2014 <code>novel-front\/...\/service\/impl\/LikeServiceImpl.java<\/code>\uff08\u7b2c 19-23 \u884c\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">@Service\n@RequiredArgsConstructor\npublic class LikeServiceImpl implements LikeService {\n    private final StringRedisTemplate redisTemplate;   \/\/ final \u5b57\u6bb5\n    ...\n}<\/code><\/pre>\n<p>\u5b83\u4f1a\u7ed9<strong>\u6240\u6709 <code>final<\/code> \u5b57\u6bb5<\/strong>\u751f\u6210\u4e00\u4e2a\u6784\u9020\u5668\uff0cSpring \u7528\u8fd9\u4e2a\u6784\u9020\u5668\u505a<strong>\u4f9d\u8d56\u6ce8\u5165<\/strong>\uff08\u6bd4 <code>@Autowired<\/code> \u5b57\u6bb5\u6ce8\u5165\u66f4\u63a8\u8350\uff09\u3002\u8fd9\u662f\u540e\u9762\u5b66\u300c\u8bf7\u6c42\u94fe\u8def\u600e\u4e48\u7ec4\u88c5\u300d\u7684\u5730\u57fa\u3002<\/p>\n<h4>\u2463 <code>@SneakyThrows<\/code> \u2014\u2014 \u628a\u53d7\u68c0\u5f02\u5e38\u300c\u5077\u5077\u300d\u53d8\u6210\u975e\u53d7\u68c0<\/h4>\n<p><strong>\u771f\u5b9e\u7528\u4f8b<\/strong> \u2014\u2014 <code>novel-front\/...\/controller\/PayController.java<\/code>\uff08\u7b2c 47 \u884c\uff09\u3001<code>JwtTokenUtil.java<\/code>\uff08\u7b2c 107 \u884c\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">@SneakyThrows\npublic void alipayCallback(HttpServletRequest request) {\n    ... \/\/ \u91cc\u9762\u76f4\u63a5\u8c03\u7528\u4f1a\u629b Exception \u7684\u65b9\u6cd5\uff0c\u4e0d\u7528\u5199 try-catch\n}<\/code><\/pre>\n<h4>\u2464 <code>@Getter<\/code> + <code>@AllArgsConstructor<\/code> + <code>@NoArgsConstructor<\/code> \u2014\u2014 \u6309\u9700\u7ec4\u5408<\/h4>\n<p><strong>\u771f\u5b9e\u7528\u4f8b<\/strong> \u2014\u2014 <code>novel-common\/...\/core\/enums\/ResponseStatus.java<\/code>\uff08\u7b2c 12-14 \u884c\uff0c\u679a\u4e3e\u7c7b\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">@Getter\n@AllArgsConstructor\n@NoArgsConstructor\npublic enum ResponseStatus {\n    OK(0, \"\u6210\u529f\"),\n    FAIL(1, \"\u5931\u8d25\");\n    ...\n}<\/code><\/pre>\n<p>\u7ed9\u679a\u4e3e\u751f\u6210 <code>getValue()\/getMsg()<\/code> \u548c\u5e26\u53c2\/\u65e0\u53c2\u6784\u9020\u5668\uff0c\u914d\u5408\u679a\u4e3e\u5e38\u91cf\u4f7f\u7528\u3002<\/p>\n<h4>\u2465 <code>@EqualsAndHashCode(callSuper = true)<\/code> \u2014\u2014 \u7ee7\u627f\u573a\u666f\u4e0b\u91cd\u5199 equals\/hashCode<\/h4>\n<p><strong>\u771f\u5b9e\u7528\u4f8b<\/strong> \u2014\u2014 <code>novel-crawl\/...\/vo\/CrawlSourceVO.java<\/code>\uff08\u7b2c 13 \u884c\uff09\uff1a<\/p>\n<pre><code class=\"language-java\">@Data\n@EqualsAndHashCode(callSuper = true)   \/\/ \u628a\u7236\u7c7b\u5b57\u6bb5\u4e5f\u7b97\u8fdb equals\/hashCode\npublic class CrawlSourceVO extends CrawlSource {<\/code><\/pre>\n<p><strong>\u6ca1\u7528\u5230<\/strong>\uff1a<code>@Builder<\/code>\u3001<code>@Accessors<\/code> \u7b49\uff08\u9879\u76ee\u98ce\u683c\u672a\u7528\uff0c\u4f46\u4f60\u5199\u65b0\u4ee3\u7801\u65f6 <code>@Builder<\/code> \u5f88\u597d\u7528\uff09\u3002<\/p>\n<h3>1.3 \u91cd\u70b9\u8ba4\u77e5\uff1a\u54ea\u4e9b\u7c7b\u7528 Lombok\uff0c\u54ea\u4e9b\u4e0d\u7528<\/h3>\n<p><strong>\u4e00\u4e2a\u5bb9\u6613\u8e29\u7684\u8ba4\u77e5\u5751<\/strong>\uff1a<code>doc\/tech-stack-learning-roadmap.md<\/code> 2.3 \u8282\u8bf4\u300c\u6240\u6709 entity \u7c7b\u90fd\u7528\u4e86 @Data\u300d\u2014\u2014<strong>\u4f46\u5b9e\u9645\u4e0d\u662f<\/strong>\u3002<\/p>\n<p>\u6253\u5f00 <code>novel-common\/...\/entity\/Book.java<\/code> \u770b\u770b\u771f\u76f8\uff1a<\/p>\n<pre><code class=\"language-java\">public class Book implements Serializable {\n    @Generated(\"org.mybatis.generator.api.MyBatisGenerator\")\n    private Long id;\n    ...\n    @Generated(\"org.mybatis.generator.api.MyBatisGenerator\")\n    public Long getId() { return id; }        \/\/ \u5b8c\u6574\u7684 getter\/setter \u90fd\u624b\u5199\u7740\n    public void setId(Long id) { this.id = id; }\n    ...\n}<\/code><\/pre>\n<p><strong><code>Book<\/code> \u7b49 24 \u4e2a\u5b9e\u4f53\u7c7b\uff0c\u4e00\u4e2a Lombok \u6ce8\u89e3\u90fd\u6ca1\u6709<\/strong>\u2014\u2014\u5b83\u4eec\u662f <strong>MyBatis Generator \u4ee3\u7801\u751f\u6210\u5668<\/strong>\u751f\u6210\u7684\u7eaf POJO\uff08\u7528 <code>@Generated(\"...MyBatisGenerator\")<\/code> \u6807\u6ce8\u6765\u6e90\uff09\uff0c\u751f\u6210\u5668\u5df2\u7ecf\u628a\u6240\u6709 getter\/setter \u5199\u5168\u4e86\uff0c\u4e0d\u9700\u8981 Lombok\u3002<\/p>\n<p>\u89c4\u5f8b\u603b\u7ed3\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7c7b<\/th>\n<th>\u7528 Lombok\uff1f<\/th>\n<th>\u4e3a\u4ec0\u4e48<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u751f\u6210\u7684\u5b9e\u4f53 <code>entity\/*.java<\/code>\uff08Book \u7b49\uff09<\/td>\n<td>\u274c \u4e0d\u7528<\/td>\n<td>\u751f\u6210\u5668\u5df2\u751f\u6210\u5168\u90e8 getter\/setter<\/td>\n<\/tr>\n<tr>\n<td>\u624b\u5199\u7684 VO \/ Controller \/ Service \/ Config \/ \u679a\u4e3e \/ \u5de5\u5177\u7c7b<\/td>\n<td>\u2705 \u7528<\/td>\n<td>\u624b\u5199\u65f6\u7528 Lombok \u7701\u6837\u677f\u4ee3\u7801<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u518d\u770b <code>BookVO extends Book<\/code> \u7684\u4f8b\u5b50\uff1a\u7236\u7c7b <code>Book<\/code> \u6ca1\u6ce8\u89e3\uff0c\u5b50\u7c7b <code>BookVO<\/code> \u624b\u5199\u6240\u4ee5\u7528 <code>@Data<\/code>\u2014\u2014<strong>\u300c\u7528\u4e0d\u7528 Lombok\u300d\u53d6\u51b3\u4e8e\u300c\u4ee3\u7801\u662f\u4e0d\u662f\u624b\u5199\u7684\u300d\uff0c\u4e0d\u662f\u300c\u662f\u4e0d\u662f entity\u300d<\/strong>\u3002<\/p>\n<h3>1.4 \u5f00\u53d1\u73af\u5883\u642d\u5efa\uff08\u7167\u505a\u4e00\u904d\uff09<\/h3>\n<p><strong>\u2460 JDK 21<\/strong><\/p>\n<ul>\n<li>\u53bb Oracle \u6216 OpenJDK \u4e0b\u8f7d JDK 21 \u5b89\u88c5\u5305\uff0c\u914d\u7f6e\u73af\u5883\u53d8\u91cf <code>JAVA_HOME<\/code>\uff0c\u628a <code>%JAVA_HOME%bin<\/code> \u52a0\u5165 <code>Path<\/code>\u3002<\/li>\n<li>\u9a8c\u8bc1\uff1a\u547d\u4ee4\u884c\u6267\u884c <code>java -version<\/code>\uff0c\u770b\u5230 <code>version \"21\"<\/code> \u5373\u6210\u529f\u3002<\/li>\n<\/ul>\n<p><strong>\u2461 IDEA + Lombok \u63d2\u4ef6<\/strong><\/p>\n<ul>\n<li>\u5b89\u88c5 IntelliJ IDEA\uff08Community \u514d\u8d39\u7248\u5373\u53ef\uff09\u3002<\/li>\n<li><strong>\u5fc5\u987b\u88c5\u63d2\u4ef6<\/strong>\uff1a<code>File \u2192 Settings \u2192 Plugins \u2192 Marketplace<\/code> \u641c\u7d22 <strong>Lombok<\/strong> \u5b89\u88c5\u3002\u4e0d\u88c5\u4f1a\u62a5\u7f16\u8bd1\u9519\u8bef\u3002<\/li>\n<li>\u82e5\u7528\u65b0\u7248 IDEA\uff0c\u53ef\u80fd\u5df2\u5185\u7f6e Lombok \u652f\u6301\uff0c\u4f46\u5efa\u8bae\u786e\u8ba4\u3002<\/li>\n<\/ul>\n<p><strong>\u2462 Maven<\/strong><\/p>\n<ul>\n<li>\u7528 IDEA \u81ea\u5e26 Maven\uff0c\u6216\u72ec\u7acb\u5b89\u88c5 Maven 3.9+\u3002<\/li>\n<li>\u5efa\u8bae\u914d <code>settings.xml<\/code> \u7684\u963f\u91cc\u955c\u50cf\u52a0\u901f\uff08<code>maven.aliyun.com<\/code>\uff09\uff0c\u5e76\u6ce8\u610f\u7b2c 3 \u8bfe\u8bb2\u7684 <code>mirrorOf=*<\/code> \u4f1a\u62e6\u622a <code>xxyopen<\/code> \u4ed3\u5e93\u7684\u5751\u3002<\/li>\n<\/ul>\n<p><strong>\u2463 \u5bfc\u5165\u9879\u76ee<\/strong><\/p>\n<ul>\n<li>IDEA \u91cc <code>Open<\/code> \u2192 \u9009\u62e9\u6839\u76ee\u5f55\u7684 <strong><code>pom.xml<\/code><\/strong> \u2192 \u4ee5 Maven \u5de5\u7a0b\u6253\u5f00\u3002\u56db\u4e2a\u6a21\u5757\u4f1a\u88ab\u6b63\u786e\u8bc6\u522b\u4e3a\u591a\u6a21\u5757\u5de5\u7a0b\u3002<\/li>\n<li>\u9996\u6b21\u4f1a\u4e0b\u8f7d\u4f9d\u8d56\uff0c\u7b49\u53f3\u4e0b\u89d2\u8fdb\u5ea6\u6761\u5b8c\u6210\u3002<\/li>\n<\/ul>\n<p><strong>\u2464 MySQL \/ Redis<\/strong><\/p>\n<ul>\n<li>\u89c1\u7b2c 1 \u8bfe\uff1a\u88c5\u597d MySQL 8.x \u4e0e Redis\uff0c\u7528 <code>doc\/sql\/novel_plus.sql<\/code> \u521d\u59cb\u5316\u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<h3>1.5 Git \u57fa\u7840\u5de5\u4f5c\u6d41\uff08\u4e86\u89e3\uff09<\/h3>\n<ul>\n<li>Git \u7528\u4e8e\u7248\u672c\u7ba1\u7406\uff1a<code>git clone &lt;\u5730\u5740&gt;<\/code> \u62ff\u5230\u4ee3\u7801 \u2192 \u5efa\u5206\u652f <code>git checkout -b feature\/xxx<\/code> \u5f00\u53d1 \u2192 <code>git add<\/code> + <code>git commit<\/code> \u63d0\u4ea4 \u2192 <code>git push<\/code> + \u53d1\u8d77 <strong>Pull Request<\/strong> \u5408\u5165\u4e3b\u5e72\u3002<\/li>\n<li><code>.gitignore<\/code> \u7528\u6765\u6392\u9664\u4e0d\u8be5\u63d0\u4ea4\u7684\u6587\u4ef6\uff08\u5982 <code>target\/<\/code>\u3001<code>.idea\/<\/code>\uff09\u3002<\/li>\n<li><strong>\u6ce8\u610f<\/strong>\uff1a\u4f60\u5f53\u524d\u8fd9\u4e2a\u672c\u5730\u76ee\u5f55<strong>\u8fd8\u4e0d\u662f git \u4ed3\u5e93<\/strong>\uff08\u6ca1\u6709 <code>.git<\/code>\uff09\uff0c\u5982\u679c\u8981\u505a\u81ea\u5df1\u7684\u7248\u672c\u7ba1\u7406\uff0c\u53ef\u5728\u9879\u76ee\u6839\u6267\u884c <code>git init<\/code> \u518d\u63d0\u4ea4\uff08\u81ea\u884c\u659f\u914c\uff0c\u522b\u628a\u542b api-key \u7684\u914d\u7f6e\u6587\u4ef6\u4f20\u4e0a\u516c\u5f00\u4ed3\u5e93\uff09\u3002<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e8c\u3001\u52a8\u624b\u7ec3\u4e60\uff08\u542b\u9a8c\u8bc1\u6807\u51c6\uff09<\/h2>\n<blockquote>\n<p>\u505a\u5b8c\u4e00\u9879\u52fe\u4e00\u9879\u3002<\/p>\n<\/blockquote>\n<h3>\u7ec3\u4e60 1\uff1a\u73af\u5883\u81ea\u68c0<\/h3>\n<ul>\n<li><strong>\u76ee\u6807<\/strong>\uff1a\u786e\u8ba4 JDK 21 \/ Maven \/ Lombok \u63d2\u4ef6\u5c31\u7eea\u3002<\/li>\n<li><strong>\u6b65\u9aa4<\/strong>\uff1a\u547d\u4ee4\u884c\u8dd1 <code>java -version<\/code>\u3001<code>mvn -version<\/code>\uff1bIDEA \u91cc <code>Settings \u2192 Plugins<\/code> \u786e\u8ba4 Lombok \u5df2\u5b89\u88c5\u3002<\/li>\n<li><strong>\u9a8c\u8bc1\u6807\u51c6<\/strong>\uff1a<code>java<\/code> \u8f93\u51fa <code>version \"21\"<\/code>\uff1b<code>mvn<\/code> \u80fd\u8f93\u51fa\u7248\u672c\uff1bIDEA \u63d2\u4ef6\u5217\u8868\u80fd\u770b\u5230 Lombok\u3002<\/li>\n<\/ul>\n<h3>\u7ec3\u4e60 2\uff1a\u5bf9\u6bd4\u4e24\u7c7b\u7c7b<\/h3>\n<ul>\n<li><strong>\u76ee\u6807<\/strong>\uff1a\u76f4\u89c2\u611f\u53d7\u300c\u7eaf POJO vs @Data\u300d\u7684\u4ee3\u7801\u91cf\u5dee\u5f02\u3002<\/li>\n<li><strong>\u6b65\u9aa4<\/strong>\uff1a\u7528 Ctrl+Shift+N \u6253\u5f00 <code>Book.java<\/code>\uff08entity\uff09\u548c <code>BookVO.java<\/code>\uff08vo\uff09\uff0c\u6bd4\u8f83\u884c\u6570\u4e0e getter\/setter \u5199\u6cd5\u3002<\/li>\n<li><strong>\u9a8c\u8bc1\u6807\u51c6<\/strong>\uff1a\u80fd\u8bf4\u51fa\u2014\u2014Book \u662f\u751f\u6210\u5668\u5199\u5168 getter\/setter \u7684\u7eaf POJO\uff1bBookVO \u53ea\u5199\u5b57\u6bb5 + \u4e00\u4e2a <code>@Data<\/code>\u3002<\/li>\n<\/ul>\n<h3>\u7ec3\u4e60 3\uff1a\u4f53\u9a8c Lombok \u81ea\u52a8\u751f\u6210<\/h3>\n<ul>\n<li><strong>\u76ee\u6807<\/strong>\uff1a\u4eb2\u773c\u770b\u5230 <code>@Data<\/code> \u751f\u6210\u4e86\u4ec0\u4e48\u3002<\/li>\n<li><strong>\u6b65\u9aa4<\/strong>\uff1a\u5728 IDEA \u7684 Scratch File \u91cc\u5199\u4e00\u4e2a <code>@Data class Student { private String name; }<\/code>\uff0c\u7136\u540e\u6309 Ctrl+F12 \u770b\u7c7b\u7ed3\u6784\u3002<\/li>\n<li><strong>\u9a8c\u8bc1\u6807\u51c6<\/strong>\uff1a\u80fd\u770b\u5230 <code>getName()\/setName()\/toString()\/equals()\/hashCode()<\/code> \u7b49\u81ea\u52a8\u751f\u6210\u7684\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<h3>\u7ec3\u4e60 4\uff08\u9009\u505a\uff09\uff1a\u9a8c\u8bc1\u63d2\u4ef6\u751f\u6548<\/h3>\n<ul>\n<li><strong>\u76ee\u6807<\/strong>\uff1a\u786e\u8ba4\u4e0d\u56e0\u7f3a\u63d2\u4ef6\u62a5\u9519\u3002<\/li>\n<li><strong>\u6b65\u9aa4<\/strong>\uff1a\u5728\u6839\u76ee\u5f55\u6267\u884c <code>mvn compile<\/code>\uff08\u6216 IDEA \u91cc Build\uff09\uff0c\u89c2\u5bdf\u662f\u5426\u62a5\u300ccannot find symbol &#8230; getXxx\u300d\u3002<\/li>\n<li><strong>\u9a8c\u8bc1\u6807\u51c6<\/strong>\uff1a<code>BUILD SUCCESS<\/code>\uff0c\u65e0\u627e\u4e0d\u5230\u65b9\u6cd5\u9519\u8bef\u3002<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e09\u3001\u672c\u8bfe\u5c0f\u7ed3<\/h2>\n<p>Lombok \u662f\u7f16\u8bd1\u671f\u751f\u6210\u6837\u677f\u4ee3\u7801\u7684\u5de5\u5177\uff0c\u9879\u76ee\u91cc 85 \u4e2a\u6587\u4ef6\u7528\u5230\u5b83\u2014\u2014\u6700\u5e38\u7528 <code>@Data<\/code>\u3001<code>@Slf4j<\/code>\u3001<code>@RequiredArgsConstructor<\/code>\u3001<code>@SneakyThrows<\/code>\uff0c\u679a\u4e3e\u548c\u7ee7\u627f\u573a\u666f\u8fd8\u4f1a\u7528\u5230 <code>@Getter\/@AllArgsConstructor\/@NoArgsConstructor<\/code>\u3001<code>@EqualsAndHashCode(callSuper=true)<\/code>\u3002<strong>\u4f46\u8981\u6ce8\u610f<\/strong>\uff1aMyBatis Generator \u751f\u6210\u7684\u5b9e\u4f53\u7c7b\u662f\u7eaf POJO\uff0c\u4e0d\u7528 Lombok\uff1bLombok \u53ea\u670d\u52a1\u4e8e\u624b\u5199\u7c7b\uff08VO\/Controller\/Service\/Config\/\u5de5\u5177\/\u679a\u4e3e\uff09\u3002\u73af\u5883\u4e0a\uff0cJDK 21 + IDEA + <strong>Lombok \u63d2\u4ef6<\/strong> + Maven \u9f50\u4e86\u5c31\u5177\u5907\u4e86\u300c\u52a8\u624b\u8dd1\u9879\u76ee\u300d\u7684\u6761\u4ef6\u3002<\/p>\n<hr \/>\n<h2>\u56db\u3001\u81ea\u6d4b\u9898<\/h2>\n<ol>\n<li>\u3010\u9009\u62e9\u3011<code>@Data<\/code> \u4f1a\u81ea\u52a8\u751f\u6210\u54ea\u4e9b\u5185\u5bb9\uff1f\uff08A. getter\/setter\u3000B. toString\u3000C. equals\/hashCode\u3000D. \u4ee5\u4e0a\u90fd\u662f\uff09<\/li>\n<li>\u3010\u9009\u62e9\u3011<code>@RequiredArgsConstructor<\/code> \u4f1a\u7ed9\u54ea\u4e9b\u5b57\u6bb5\u751f\u6210\u6784\u9020\u5668\uff1f\uff08A. static \u5b57\u6bb5\u3000B. final \u5b57\u6bb5\u3000C. transient \u5b57\u6bb5\u3000D. \u6240\u6709\u5b57\u6bb5\uff09<\/li>\n<li>\u3010\u9009\u62e9\u3011\u4e0b\u5217\u54ea\u4e2a\u6ce8\u89e3\u53ef\u4ee5\u628a\u53d7\u68c0\u5f02\u5e38\u300c\u5077\u5077\u300d\u53d8\u6210\u975e\u53d7\u68c0\u3001\u514d\u5199 try-catch\uff1f\uff08A. <code>@Slf4j<\/code>\u3000B. <code>@Data<\/code>\u3000C. <code>@SneakyThrows<\/code>\u3000D. <code>@Getter<\/code>\uff09<\/li>\n<li>\u3010\u7b80\u7b54\u3011\u4e3a\u4ec0\u4e48 MyBatis Generator \u751f\u6210\u7684 <code>Book.java<\/code> \u4e0d\u9700\u8981 Lombok\uff1f<\/li>\n<li>\u3010\u7b80\u7b54\u3011<code>@Slf4j<\/code> \u5728\u7c7b\u91cc\u63d0\u4f9b\u4e86\u54ea\u4e2a\u53d8\u91cf\u540d\u53ef\u4ee5\u76f4\u63a5\u7528\uff1f<\/li>\n<\/ol>\n<blockquote>\n<p>\u7b54\u6848\uff1a1-D\u30012-B\u30013-C\uff08\u89c1 1.2\uff09\u30014-\u751f\u6210\u5668\u5df2\u751f\u6210\u5b8c\u6574 getter\/setter\uff08\u89c1 1.3\uff09\u30015-<code>log<\/code>\uff08\u89c1 1.2\u2461\uff09\u3002<\/p>\n<\/blockquote>\n<hr \/>\n<h2>\u4e94\u3001\u53c2\u8003\u8d44\u6e90<\/h2>\n<ul>\n<li>\u672c\u8bfe\u7a0b\u5927\u7eb2\uff1a<code>Tutorial\/\u8bfe\u7a0b\u5927\u7eb2-30\u8282\u8bfe.md<\/code> \u2192 \u7b2c 4 \u8bfe<\/li>\n<li>\u6280\u672f\u6808\u8def\u7ebf\uff1a<code>doc\/tech-stack-learning-roadmap.md<\/code> \u2192 2.3 \u8282 Lombok\uff08\u6ce8\u610f\u5176\u300c\u6240\u6709 entity \u7528 @Data\u300d\u7684\u8bf4\u6cd5\u4e0e\u6e90\u7801\u4e0d\u7b26\uff09<\/li>\n<li>\u5b98\u65b9\u6587\u6863\uff1aprojectlombok.org\/features<\/li>\n<li>\u73af\u5883\u4e0b\u8f7d\uff1aOracle JDK 21 \u4e0b\u8f7d\u9875\u3001IntelliJ IDEA \u5b98\u7f51<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c 4 \u8bfe Lombok + \u5f00\u53d1\u73af\u5883\u642d\u5efa \u672c\u8bfe\u4e24\u90e8\u5206\uff1a\u2460 \u8ba4\u8bc6 Lombok\u2014\u2014\u4e00\u4e2a\u5e2e\u4f60\u5c11\u5199\u300c\u6837\u677f\u4ee3\u7801\u300d\u7684\u5229 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[22],"class_list":["post-579","post","type-post","status-publish","format-standard","hentry","category-project","tag-22"],"_links":{"self":[{"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/posts\/579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/comments?post=579"}],"version-history":[{"count":0,"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/posts\/579\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/media?parent=579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/categories?post=579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kirasu.cn\/index.php\/wp-json\/wp\/v2\/tags?post=579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}