{"id":5470,"date":"2025-12-26T13:39:00","date_gmt":"2025-12-26T05:39:00","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=5470"},"modified":"2025-12-26T13:39:00","modified_gmt":"2025-12-26T05:39:00","slug":"%e7%83%82%e5%b0%be%e4%ba%86%ef%bc%8cspring7%e5%ae%98%e5%ae%a3%e7%a7%bb%e9%99%a4jsr305%ef%bc%8c%e8%81%94%e6%89%8bjspecify%e6%95%b4%e9%a1%bfnonnull","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=5470","title":{"rendered":"\u70c2\u5c3e\u4e86\uff0cSpring7\u5b98\u5ba3\u79fb\u9664JSR305\uff0c\u8054\u624bJSpecify\u6574\u987f@NonNull"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e0d\u77e5\u9053\u5927\u5bb6\u6ce8\u610f\u6ca1\u6ce8\u610f\u5230\uff0cSpring 7.x\u3001Spring Boot 4.x \u4e5f\u6216\u8005\u8bf4\u662f Spring Cloud 2025.x\uff0c\u5b83\u4eec\u90fd\u5728\u7248\u672c\u53d1\u5e03\u8bf4\u660e\u91cc\u63d0\u5230\u4e86<code>@NonNull<\/code>\u6ce8\u89e3\u6216\u8005\u662f\u5bf9 JSpecify \u7684\u652f\u6301\u3002\u6309\u8bf4<code>@NonNull<\/code>\u6ce8\u89e3\u5e76\u4e0d\u65b0\u9c9c\u5440\uff0c\u4e3a\u5565\u5b83\u4eec\u53c8\u65e7\u4e8b\u91cd\u63d0\u4e86\u5462\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5509\uff0c\u4eca\u5929\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u804a\u804a\u8fd9\u5176\u4e2d\u7684\u6545\u4e8b\u3002\u4e00\u4e2a\u5929\u4e0b\u82e6 @NonNull \u4e45\u77e3\uff0cJSpecify \u7ec8\u7ed3 Java \u7a7a\u6307\u9488\u6ce8\u89e3\u5341\u5e74\u4e4b\u4e71\u7684\u6545\u4e8b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">@NonNull<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">@NonNull \u4e0d\u662f\u4e00\u4e2a\u201c\u65b0\u6ce8\u89e3\u201d\uff0c\u800c\u662f Java \u751f\u6001\u5bf9\u7a7a\u6307\u9488\u5f02\u5e38\u7684\u7ec8\u6781\u7b54\u6848\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u76f8\u4fe1\u5f88\u591a Java \u5f00\u53d1\u8005\u90fd\u9047\u5230\u8fc7\u8fd9\u6837\u7684\u573a\u666f\u3002\u5f53\u4f60\u60f3\u6807\u8bb0\u4e00\u4e2a\u53c2\u6570\u4e0d\u5141\u8bb8\u4e3a null \u65f6\uff0cIDEA \u81ea\u52a8\u8865\u5168\u4f1a\u53cb\u597d\u5730\u63d0\u9192\u4f60\uff0c\u8fd9\u91cc\u6709 5 \u4e2a<code>@NonNull<\/code>\uff0c\u4f60\u60f3\u8981\u54ea\u4e2a\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>javax.annotation.Nonnull<\/code><\/li><li><code>org.springframework.lang.NonNull<\/code><\/li><li><code>lombok.NonNull<\/code><\/li><li><code>androidx.annotation.NonNull<\/code><\/li><li><code>com.alibaba.nacos.shaded.javax.annotation.Nonnull<\/code><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u9762\u5bf9\u8fd9\u4e00\u5806\u201cNonNull\u201d\uff0c\u6709\u4e9b\u4eba\u53ef\u80fd\u4f1a\u72af\u9009\u62e9\u56f0\u96be\u75c7\u3002\u9009 javax\uff1f\u8fd8\u662f Spring \u7684\uff1f\u66f4\u8be1\u5f02\u7684\u662f\uff0c\u5f53\u4f60\u4f7f\u7528<code>Nacos<\/code>\u81ea\u5e26\u7684<code>@Nonnull<\/code>\u65f6\uff0cIDEA \u5c45\u7136\u4e0d\u7ed9\u4f60\u4efb\u4f55\u8b66\u544a\uff1b\u4f46\u6362\u6210<code>Spring<\/code>\u7684<code>@NonNull<\/code>\u540e\uff0c\u9ec4\u8272\u8b66\u544a\u7acb\u523b\u51fa\u73b0\u3002\u8fd9\u96be\u9053\u662f IDEA \u4e5f\u5b66\u4f1a\u4e86\u201c\u770b\u4eba\u4e0b\u83dc\u789f\u201d\u4e86\u5417\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u8bd5\u4e00\u8bd5\uff0c\u770b\u770b\u4e0d\u540c\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5b9e\u9a8c1\uff1a\u4f7f\u7528Spring\u7684@NonNull\npublic void test(@org.springframework.lang.NonNull String a) {}\ntest(null); \/\/ IDEA\u8b66\u544a\uff1a\u4f20\u9012\u4e86null\u7ed9\u975e\u7a7a\u53c2\u6570\n\n\/\/ \u5b9e\u9a8c2\uff1a\u4f7f\u7528Nacos\u7684@Nonnull  \npublic void test(@com.alibaba.nacos.shaded.javax.annotation.Nonnull String a) {}\ntest(null); \/\/ IDEA\u5b89\u9759\u5982\u9e21\uff0c\u6beb\u65e0\u53cd\u5e94\n\n\/\/ \u5b9e\u9a8c3\uff1a\u4f7f\u7528\u539f\u751f\u7684javax.annotation.Nonnull\npublic void test(@javax.annotation.Nonnull String a) {}\ntest(null); \/\/ IDEA\u518d\u6b21\u8b66\u544a<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4ec0\u4e48\u540c\u6837\u7684\u8bed\u4e49\uff0cIDEA \u8981\u533a\u522b\u5bf9\u5f85\uff1f\u4e3a\u4e86\u63ed\u5f00\u8fd9\u4e2a\u8c1c\u56e2\uff0c\u8981\u4ece\u4e00\u4e2a\u201c\u6c89\u7761\u201d\u4e86 18 \u5e74\u7684\u6807\u51c6\u8bf4\u8d77\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JSR305<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u77e5\u9053\uff0c\u5927\u5bb6\u8fd8\u8bb0\u5f97\u8fd9\u4e2a\u89c4\u8303\u4e0d\uff1f\u5927\u5bb6\u53ef\u4ee5\u627e\u627e\u81ea\u5df1\u7684\u9879\u76ee\u91cc\uff0c\u662f\u4e0d\u662f\u6709\u4e00\u4e2a jsr305.jar \u5305\u6587\u4ef6\u3002\u8fd9\u4e2a jsr305 \u6211\u6b63\u770b\u53cd\u770b\uff0c\u5b83\u90fd\u4e0d\u50cf\u662f Java \u7684\u201c\u4eb2\u513f\u5b50\u201d\uff0c\u66f4\u50cf\u662f\u88ab Java \u5b98\u65b9\u7ed9\u9057\u5fd8\u4e86\u7684 Java \u89c4\u8303\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\u7684<code>NonNull<\/code>\u5f88\u6df7\u4e71\uff0c\u800c\u8fd9\u4e00\u5207\u6df7\u4e71\u7684\u6839\u6e90\uff0c\u90fd\u6307\u5411\u4e00\u4e2a\u7f16\u53f7<code>JSR-305<\/code>\uff08<code>https:\/\/jcp.org\/en\/jsr\/detail?id=305<\/code>\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4ec0\u4e48\u662f JSR305\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">JSR305\uff08<code>Java Specification Request 305<\/code>\uff09\u662f 2006 \u5e74\u542f\u52a8\u7684\u4e00\u4e2a Java \u89c4\u8303\u63d0\u6848\uff0c\u5168\u79f0\u662f<code>Annotations for Software Defect Detection<\/code>\u8f6f\u4ef6\u7f3a\u9677\u68c0\u6d4b\u6ce8\u89e3\u3002\u5b83\u671f\u671b\u4e3a Java \u5f15\u5165\u4e00\u5957\u6807\u51c6\u7684\u9759\u6001\u5206\u6790\u6ce8\u89e3\uff0c\u7528\u4e8e\u5e2e\u52a9 FindBugs\u3001IDE \u7b49\u5de5\u5177\u68c0\u6d4b\u6f5c\u5728\u7684\u4ee3\u7801\u7f3a\u9677\uff0c\u6838\u5fc3\u5c31\u662f<code>@Nonnull<\/code>\u3001<code>@Nullable<\/code>\u3001<code>@CheckForNull<\/code>\u7b49\u7a7a\u6307\u9488\u76f8\u5173\u7684\u6ce8\u89e3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u6ce8\u89e3\u5728<code>javax.annotation<\/code>\u5305\u4e0b\uff0c\u7531<code>jsr305.jar<\/code>\u63d0\u4f9b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JSR305 \u7684\u4f11\u7720\u4e4b\u8c1c<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u800c\uff0c\u8fd9\u4e2a\u59cb\u4e8e 2006 \u5e74\u7684\u89c4\u8303\uff0c\u5728 2025 \u5e74\u7684\u4eca\u5929\uff0c\u72b6\u6001\u4ecd\u7136\u662f<code>Dormant\uff08\u4f11\u7720\uff09<\/code>\u3002\u8fd9\u610f\u5473\u7740\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u65e0\u4eba\u7ef4\u62a4\uff1a\u6ca1\u6709\u5b98\u65b9\u56e2\u961f\u6301\u7eed\u63a8\u52a8\u6f14\u8fdb<\/li><li>\u8bbe\u8ba1\u7f3a\u9677\uff1a\u539f\u59cb\u8bbe\u8ba1\u5bf9\u6cdb\u578b\u3001\u6570\u7ec4\u3001\u7c7b\u578b\u8fb9\u754c\u7b49\u590d\u6742\u573a\u666f\u652f\u6301\u4e0d\u8db3<\/li><li>\u751f\u6001\u5206\u88c2\uff1a\u5404\u5927\u5382\u5546\uff08Google\u3001Spring\u3001JetBrains\u3001Alibaba \u7b49\uff09\u5404\u81ea\u5b9e\u73b0\uff0c\u4e92\u4e0d\u517c\u5bb9<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u800c\u4e14\uff0c\u8fd9\u4e2a\u4f11\u7720\uff0c\u65f6\u95f4\u4e5f\u592a\u957f\u4e86\u5427\u3002\u90fd\u5feb 20 \u5e74\u4e86\uff0c\u4e00\u76f4\u6ca1\u5565\u52a8\u9759\uff0c\u4ece 2006 \u5230\u76ee\u524d\u7684\u72b6\u6001\u6807\u8bb0\u4e3a\u4e86<code>Dormant<\/code>\uff0c\u610f\u601d\u662f\u4f11\u7720\u7684<code>JSR305<\/code>\u5176\u5b9e\u6ca1\u4eba\u7ba1\u3002\u7ec6\u7ec6\u7b97\u4e0b\u6765\uff0c\u5b83\u5927\u4e8e\u201c\u5b58\u6d3b\u201d\u4e86\u7ea6 6 \u5e74\u65f6\u95f4\uff0c\u5176\u5b83\u65f6\u95f4\u90fd\u662f\u201c\u4f11\u7720\u201d\u72b6\u6001\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b63\u662f\u8fd9\u79cd\u201c\u653e\u517b\u201d\u72b6\u6001\uff0c\u5bfc\u81f4 Spring\u3001Nacos\u3001Lombok \u7b49\u6846\u67b6\u4e0d\u5f97\u4e0d<code>\u91cd\u590d\u9020\u8f6e\u5b50<\/code>\uff0c\u5b9a\u4e49\u81ea\u5df1\u7684 @NonNull \u6ce8\u89e3\uff0c\u4f46\u6bcf\u4e2a\u6ce8\u89e3\u7684\u201c\u6cd5\u5f8b\u6548\u529b\u201d\u5374\u5404\u4e0d\u76f8\u540c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JSpecify \u7684\u6551\u8d4e<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u65e2\u7136 JSR305 \u9192\u4e0d\u8fc7\u6765\uff0c\u90a3\u6211\u4eec\u5c31\u518d\u9020\u4e00\u4e2a\u6807\u51c6\u3002\u8fd9\u662f Google\u3001JetBrains\u3001Uber\u3001Pivotal\u3001Square \u7b49\u5de8\u5934\u5728 2019 \u5e74\u8fbe\u6210\u7684\u5171\u8bc6\uff0c\u8fd9\u5c31\u662f\u5927\u5382\u8054\u76df\u7684\u6551\u8d4e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JSpecify \u662f\u4ec0\u4e48\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">JSpecify \u662f\u4e00\u4e2a\u5168\u65b0\u7684\u3001\u72ec\u7acb\u4e8e JSR \u7684\u6ce8\u89e3\u5e93\u9879\u76ee\uff0c\u5176\u4f7f\u547d\u662f\uff1a<code>\u4e3a Java \u63d0\u4f9b\u4e00\u5957\u7cbe\u786e\u3001\u7edf\u4e00\u7684\u7a7a\u6307\u9488\u6ce8\u89e3\u6807\u51c6<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b98\u7f51\u7684\u5b9a\u4e49\u4e5f\u975e\u5e38\u7b80\u6d01\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>JSpecify provides precise, tool-friendly annotations for Java nullness analysis, enabling better static checking and Kotlin interoperability.<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ffb\u8bd1\u8fc7\u6765\uff0c\u5927\u81f4\u5c31\u662f\uff1a<code>JSpecify \u4e3a Java \u4e2d\u7684 null \u60c5\u51b5\u5206\u6790\u63d0\u4f9b\u4e86\u7cbe\u786e\u4e14\u6613\u4e8e\u4f7f\u7528\u7684\u6ce8\u91ca\u529f\u80fd\uff0c\u4ece\u800c\u6709\u52a9\u4e8e\u63d0\u5347\u9759\u6001\u68c0\u67e5\u80fd\u529b\u5e76\u589e\u5f3a Kotlin \u7684\u4e92\u64cd\u4f5c\u6027<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u7684\u6838\u5fc3\u4f18\u52bf\u6709\u4ee5\u4e0b 4 \u70b9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u3001\u5f7b\u5e95\u89e3\u51b3\u95ee\u9898\uff1a\u652f\u6301\u6cdb\u578b\u3001\u6570\u7ec4\u3001\u53d8\u957f\u53c2\u6570\u7684\u5143\u7d20\u7ea7\u7a7a\u6307\u9488\u6ce8\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u53ef\u4ee5\u7cbe\u786e\u5230\u6cdb\u578b\u53c2\u6570\nList&lt;@NonNull String&gt; nonNullElements;\n\n\/\/ \u6570\u7ec4\u5143\u7d20\u7684\u7a7a\u6027\nString @NonNull [] nonNullArray;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u3001\u89c4\u8303\u660e\u786e\u3002\u63d0\u4f9b\u8be6\u7ec6\u7684\u8bed\u4e49\u89c4\u8303\uff0c\u907f\u514d\u6b67\u4e49\u3002<br>\n\u7b2c\u4e09\u3001\u5927\u5382\u80cc\u4e66\u3002\u7531 Google\u3001JetBrains\u3001Microsoft\u3001Uber\u3001Spring \u7b49\u8054\u5408\u7ef4\u62a4\u3002<br>\n\u7b2c\u56db\u3001\u96f6\u4f9d\u8d56\u3002\u7eaf\u6ce8\u89e3\u5e93\uff0c\u4e0d\u4f9d\u8d56\u8fd0\u884c\u65f6\u7ec4\u4ef6\u3002<br>\n\u7b2c\u4e94\u3001\u5b8c\u7f8e\u517c\u5bb9 Kotlin\u3002\u89e3\u51b3 JSR305 \u4e0e Kotlin \u4e92\u64cd\u4f5c\u7684\u957f\u671f\u75db\u70b9\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cc\u7a0b\u7891\u65f6\u523b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">2024 \u5e74\uff0cJSpecify 1.0.0 \u6b63\u5f0f\u7248\u53d1\u5e03\u3002\u8fd9\u662f Java \u7a7a\u6307\u9488\u6ce8\u89e3\u6df7\u4e71\u53f2\u7684\u7ec8\u7ed3\u65f6\u523b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece 2019 \u5e74\u7684\u840c\u82bd\uff0c\u5230 2024 \u5e74\uff0c\u5386\u65f6\u8fd1 5 \u5e74\uff0cJSpecify \u7ec8\u4e8e\u8fce\u6765\u4e86\u5b83\u7684\u91cc\u7a0b\u7891\u65f6\u523b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Spring 7 \u62e5\u62b1 JSpecify<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Spring Framework 7.0 \u7684 Release Notes \u4e2d\uff0c\u5b98\u65b9\u7528\u4e86\u4e00\u4e2a\u4e13\u95e8\u7684\u7ae0\u8282\u5ba3\u544a\u8fd9\u4e00\u53d8\u9769\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Spring nullness annotations with JSR 305 semantics are deprecated in favor of JSpecify annotations<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e26\u6709 JSR 305 \u8bed\u4e49\u7684 Spring \u7a7a\u503c\u6ce8\u89e3\u5df2\u88ab\u5f03\u7528\uff0c\u53d6\u800c\u4ee3\u4e4b\u7684\u662f JSpecify \u6ce8\u89e3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u770b\u8d77\u6765\uff0cSpring \u597d\u50cf\u65e9\u5c31\u770b\u4e0d\u8fc7\u8fd9\u4e2a jsr 305 \u4e86\u3002\u4e13\u95e8\u7528\u4e00\u7ae0\uff0c\u5927\u7bc7\u5e45\u7684\u4ecb\u7ecd JSpecify\uff0c\u50cf\u662f\u4e00\u4e2a\u201c\u72ec\u7acb\u5ba3\u8a00\u201d\u4e00\u6837\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Spring 7 \u505a\u4e86\u4ec0\u4e48\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u603b\u7ed3\u4e0b\u6765\uff0c\u6709\u4e0b\u9762 4 \u70b9\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5168\u91cf\u8fc1\u79fb\uff1aSpring Framework \u4ee3\u7801\u5e93\u5df2\u5c06\u6240\u6709\u7a7a\u6307\u9488\u6ce8\u89e3\u8fc1\u79fb\u5230 JSpecify<\/li><li>\u529f\u80fd\u589e\u5f3a\uff1a\u73b0\u5728\u53ef\u4ee5\u7cbe\u786e\u6307\u5b9a\u6570\u7ec4\/\u53d8\u957f\u53c2\u6570\u5143\u7d20\u7684\u7a7a\u6027<\/li><li>Kotlin \u53cb\u597d\uff1a\u4fee\u590d\u4e86 JSR305 \u5728 Kotlin \u4e2d\u5bfc\u81f4\u7684 nullability \u4e0d\u4e00\u81f4\u95ee\u9898<\/li><li>\u5e73\u6ed1\u8fc7\u6e21\uff1a\u539f\u6709<code>spring-core<\/code>\u4e2d\u7684<code>@NonNull<\/code>\u3001<code>@Nullable<\/code>\u88ab\u6807\u8bb0\u4e3a<code>@Deprecated<\/code>\uff0c\u4f46\u4fdd\u7559\u517c\u5bb9<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\u662f\u4e3a\u4e86\u517c\u5bb9\u6027\uff0c\u770b\u770b\u6211\u6628\u5929\u90a3\u7bc7\u6587\u7ae0\uff0cJava \u7684\u201c\u7529\u94fe\u5b50\u201d\uff0c\u548c Spring \u7684\u51b3\u7edd\u679c\u65ad\uff0c\u4e00\u4e2a\u50cf\u5728\u5929\u4e0a\uff0c\u4e00\u4e2a\u50cf\u5728\u5730\u4e0a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u800c\u4e14 Spring \u5b98\u65b9\u7ed9\u51fa\u7684\u7406\u7531\u975e\u5e38\u76f4\u63a5\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>JSR305 \u5904\u4e8e Dormant \u72b6\u6001\uff0c\u7f3a\u4e4f\u7ef4\u62a4<\/li><li>JSpecify \u63d0\u4f9b\u4e86\u66f4\u7cbe\u786e\u7684\u89c4\u8303<\/li><li>\u66f4\u597d\u7684\u5de5\u5177\u94fe\u652f\u6301\uff08IDEA\u3001ErrorProne\u3001NullAway \u7b49\uff09<\/li><li>\u5f7b\u5e95\u89e3\u51b3\u4e0e Kotlin \u7684\u4e92\u64cd\u4f5c\u95ee\u9898<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528\u6216\u8fc1\u79fb\u793a\u4f8b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u65e7\u4ee3\u7801\uff0cSpring 6.x \u7b49\u7248\u672c\u4e2d\u7684\u7528\u6cd5\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import org.springframework.lang.NonNull;\nimport org.springframework.lang.Nullable;\n\npublic class UserService {\n    public User getUser(@NonNull String id) {\n        return userRepository.findById(id);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b0\u7248 Spring 7.x \u4e2d\u7684\u76f8\u5173\u6ce8\u89e3\u7528\u6cd5\u5982\u4e0b\u4ee3\u7801\u6240\u793a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import org.jspecify.annotations.NonNull;\nimport org.jspecify.annotations.Nullable;\n\npublic class UserService {\n    public User getUser(@NonNull String id) {\n        return userRepository.findById(id);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u660e\u663e\uff0c\u5305\u540d\u4ece<code>org.springframework.lang<\/code>\u53d8\u4e3a<code>org.jspecify.annotations<\/code>\uff0c\u4f46 IDE \u548c\u7f16\u8bd1\u5668\u7684\u68c0\u67e5\u7cbe\u5ea6\u5c06\u5927\u5e45\u63d0\u5347\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">IDEA \u533a\u522b\u5bf9\u5f85\u7684\u771f\u76f8<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u56de\u5230\u5f00\u5934\u7684\u5b9e\u9a8c\uff0c\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u5b8c\u6574\u89e3\u91ca IDEA \u7684\u884c\u4e3a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Nacos\u7684@Nonnull\u5b9e\u73b0\n@Retention(RetentionPolicy.CLASS)\npublic @interface Nonnull {}  \/\/ \u5149\u79c3\u79c3\u7684\u6ce8\u89e3\uff0c\u65e0\u4efb\u4f55\u5143\u4fe1\u606f\n\n\/\/ JSR305\u7684@Nonnull\u5b9e\u73b0  \n@Retention(RetentionPolicy.RUNTIME)\npublic @interface Nonnull {} \/\/ \u540c\u6837\u5149\u79c3\u79c3\n\n\/\/ Spring\u7684@NonNull\u5b9e\u73b0\n@org.springframework.lang.NonNull\n\/\/ \u5143\u6ce8\u89e3\u53e0\u52a0\uff0cIDEA \u8bc6\u522b\u5230\u4e86 JSR305 \u7248\u672c\n@javax.annotation.Nonnull  \npublic @interface NonNull {}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u6838\u5fc3\u7684\u539f\u56e0\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>IDEA \u5185\u7f6e\u4e86\u5bf9<code>javax.annotation.Nonnull<\/code>\u7684\u786c\u7f16\u7801\u8bc6\u522b<\/li><li>Spring \u4e3a\u4e86\u517c\u5bb9 JSR305\uff0c\u5728\u81ea\u5df1\u7684\u6ce8\u89e3\u4e0a\u52a0\u4e86\u5143\u6ce8\u89e3<code>@javax.annotation.Nonnull<\/code><\/li><li>Nacos \u7684\u6ce8\u89e3\u6ca1\u6709\u6dfb\u52a0\u4efb\u4f55\u5143\u4fe1\u606f\uff0cIDEA \u4e0d\u8ba4\u8bc6\u5b83\uff0c\u6240\u4ee5\u4e0d\u4f1a\u89e6\u53d1\u68c0\u67e5<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u79cd\u201c\u533a\u522b\u5bf9\u5f85\u201d\u6070\u6070\u66b4\u9732\u4e86 JSR305 \u751f\u6001\u7684\u81f4\u547d\u95ee\u9898\uff0c<code>\u6ca1\u6709\u5de5\u5177\u5c42\u9762\u7684\u7edf\u4e00\u6807\u51c6<\/code>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JCP \u65e0\u4f5c\u4e3a<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5386\u53f2\u7684\u8f66\u8f6e\u6eda\u6eda\u5411\u524d\uff0c\u4ece\u6df7\u4e71\u5230\u7edf\u4e00\uff0c\u4ece JSR305 \u5230 JSpecify\uff0c\u8bf4\u767d\u4e86\u5c31\u662f JCP \u7684\u201c\u65e0\u4f5c\u4e3a\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u662f\u5b83\u4eec\u7684\u65f6\u95f4\u7ebf\u56de\u987e\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>2006 \u5e74\uff1aJSR305 \u542f\u52a8\uff0c\u63d0\u51fa\u7a7a\u6307\u9488\u6ce8\u89e3\u8349\u6848<\/li><li>2012 \u5e74\uff1aJSR305 \u8fdb\u5165 Dormant \u72b6\u6001\uff0c\u751f\u6001\u5f00\u59cb\u5206\u88c2<\/li><li>2019 \u5e74\uff1aJSpecify \u9879\u76ee\u542f\u52a8\uff0c\u5927\u5382\u8054\u624b<\/li><li>2024 \u5e74\uff1aJSpecify 1.0.0 \u53d1\u5e03<\/li><li>2025 \u5e74\uff1aSpring 7.0 \u6b63\u5f0f\u91c7\u7528 JSpecify\uff0c\u5ba3\u544a JSR305 \u65f6\u4ee3\u7ec8\u7ed3<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8868\u660e\u770b\u50cf\u662f\u6280\u672f\u6f14\u8fdb\u7684\u80dc\u5229\uff0c\u5b9e\u9645\u4e0a\u66f4\u503c\u5f97\u79f0\u8d5e\u7684\u662f\u793e\u533a\u534f\u4f5c\u7684\u5178\u8303\u3002\u5f53 JCP\uff08Java Community Process\uff09\u65e0\u6cd5\u63a8\u52a8\u4e00\u4e2a\u4f11\u7720\u7684 JSR \u65f6\uff0cGoogle\u3001JetBrains\u3001Pivotal \u7b49\u4f01\u4e1a\u9009\u62e9<code>\u7ed5\u5f00\u5b98\u50da\u6d41\u7a0b\uff0c\u7528\u4ee3\u7801\u8bf4\u8bdd<\/code>\uff0c\u6700\u7ec8\u521b\u9020\u4e86\u4e00\u4e2a\u66f4\u597d\u7684\u6807\u51c6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ed3\u8bed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u201c\u5929\u4e0b\u5171\u4e3b Java\u201d\uff0c\u5929\u4e0b\u53c8\u82e6 @NonNull \u4e45\u77e3\uff0c\u5982\u4eca\u7ec8\u89c1\u66d9\u5149\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">JSpecify \u4e0d\u662f\u7b80\u5355\u7684\u201c\u53c8\u4e00\u4e2a\u6ce8\u89e3\u5e93\u201d\uff0c\u800c\u662f Java \u751f\u6001\u5bf9\u8fc7\u53bb 18 \u5e74\u7a7a\u6307\u9488\u6ce8\u89e3\u6df7\u4e71\u7684\u5f7b\u5e95\u53cd\u601d\u4e0e\u91cd\u6784\u3002Spring 7 \u7684\u62e5\u62b1\uff0c\u6807\u5fd7\u7740\u4e3b\u6d41\u6846\u67b6\u7684\u5171\u8bc6\u5df2\u7ecf\u5f62\u6210\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u6211\u4eec\u5927\u591a\u6570 Java \u5f00\u53d1\u8005\u800c\u8a00\uff0c\u8fd9\u610f\u5473\u7740\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u66f4\u5c11\u7684\u56f0\u60d1\uff1a\u518d\u4e5f\u4e0d\u7528\u7ea0\u7ed3\u7528\u54ea\u4e2a @NonNull<\/li><li>\u66f4\u5f3a\u7684\u68c0\u67e5\uff1a\u5de5\u5177\u94fe\u80fd\u7cbe\u51c6\u53d1\u73b0 null \u5b89\u5168\u95ee\u9898<\/li><li>\u66f4\u597d\u7684\u4e92\u64cd\u4f5c\uff1aJava \u4e0e Kotlin \u7684\u65e0\u7f1d\u534f\u4f5c<\/li><li>\u66f4\u7edf\u4e00\u7684\u6807\u51c6\uff1a\u5927\u5382\u8054\u5408\u7ef4\u62a4\uff0c\u957f\u671f\u7a33\u5b9a<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5386\u53f2\u4f1a\u9057\u5fd8 JSR305\uff0c\u540c\u6837\u4e5f\u4f1a\u8ba9\u6211\u4eec\u8bb0\u4f4f\u8fd9\u4e2a\u5305\u540d<code>org.jspecify.annotations<\/code>\uff0c\u5b83\u6bd4\u5c06\u662f\u672a\u6765\u5341\u5e74 Java \u7a7a\u6307\u9488\u5b89\u5168\u7684\u4ee3\u540d\u8bcd\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u8d44\u6599<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><code>https:\/\/github.com\/spring-projects\/spring-framework\/wiki\/Spring-Framework-7.0-Release-Notes<\/code><\/li><li>JSpecify \u5b98\u65b9\u6587\u6863: <code>https:\/\/jspecify.dev\/docs\/user-guide\/<\/code><\/li><li><code>https:\/\/jcp.org\/en\/jsr\/detail?id=305<\/code><\/li><\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=5470\">\u70c2\u5c3e\u4e86\uff0cSpring7\u5b98\u5ba3\u79fb\u9664JSR305\uff0c\u8054\u624bJSpecify\u6574\u987f@NonNull<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u77e5\u9053\u5927\u5bb6\u6ce8\u610f\u6ca1\u6ce8\u610f\u5230\uff0cSpring 7.x\u3001Spring Boot 4.x \u4e5f\u6216\u8005\u8bf4\u662f Spring Clo [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[2077,551,587,1638,1045],"class_list":["post-5470","post","type-post","status-publish","format-standard","hentry","category-java","tag-jsp","tag-spring","tag-spring-boot","tag-springcloud","tag-1045"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5470"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5470\/revisions"}],"predecessor-version":[{"id":5471,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5470\/revisions\/5471"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}