{"id":159,"date":"2026-04-30T17:38:04","date_gmt":"2026-04-30T09:38:04","guid":{"rendered":"https:\/\/larkdrop.cafe\/?p=159"},"modified":"2026-04-30T17:38:05","modified_gmt":"2026-04-30T09:38:05","slug":"%e6%b3%a8%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/larkdrop.cafe\/index.php\/2026\/04\/30\/%e6%b3%a8%e8%a7%a3\/","title":{"rendered":"\u6ce8\u89e3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Annotation\u5176\u5b9e\u662f\u4ee3\u7801\u91cc\u7684\u7279\u6b8a\u6807\u8bb0\uff0c\u8fd9\u4e9b\u6807\u8bb0\u53ef\u4ee5\u5728\u7f16\u8bd1\u3001\u7c7b\u52a0\u8f7d\u3001\u8fd0\u884c\u65f6\u88ab\u8bfb\u53d6\uff0c\u5e76\u6267\u884c\u76f8\u5e94\u7684\u5904\u7406<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4f7f\u7528Annotation\uff0c\u7a0b\u5e8f\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5728\u4e0d\u6539\u53d8\u539f\u6709\u903b\u8f91\u7684\u60c5\u51b5\u4e0b\uff0c\u5728\u6e90\u6587\u4ef6\u5d4c\u5165\u4e00\u4e9b\u8865\u5145\u4fe1\u606f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Annotation\u5c31\u50cf\u4fee\u9970\u7b26\u4e00\u6837\u88ab\u4f7f\u7528\uff0c\u53ef\u7528\u4e8e\u4fee\u9970\u7c7b\u3001\u6784\u9020\u5668\u3001\u65b9\u6cd5\u3001\u6210\u5458\u53d8\u91cf\u3001\u53c2\u6570&#8230;\uff0c\u8fd9\u4e9b\u4fe1\u606f\u88ab\u5b58\u50a8\u5728Annotation\u7684\u201c\u5c5e\u6027\u540d=\u5c5e\u6027\u503c\u201d\u952e\u503c\u5bf9\u4e2d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6ce8\u89e3\u5b9a\u4e49<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6743\u9650\u4fee\u9970\u7b26 @interface \u6ce8\u89e3\u540d\u5b57{<br> &nbsp; &nbsp;\/\/ \u6ce8\u89e3\u4f53\u5b9a\u4e49<br> &nbsp; &nbsp;\u5c5e\u6027\u7c7b\u578b \u5c5e\u6027\u540d();<br> &nbsp; &nbsp;\u5c5e\u6027\u7c7b\u578b \u5c5e\u6027\u540d();<br> &nbsp; &nbsp;\u5c5e\u6027\u7c7b\u578b \u5c5e\u6027\u540d();<br> &nbsp;  ......<br> &nbsp; &nbsp;\u5c5e\u6027\u7c7b\u578b \u5c5e\u6027\u540d() default value;<br>}<br>\u4e3e\u4f8b:<br>public @interface Override {<br>}<br>\u200b<br>\u5c5e\u6027\u7c7b\u578b:<br> &nbsp; &nbsp;\u57fa\u672c\u6570\u636e\u7c7b\u578b<br> &nbsp; &nbsp;String\u7c7b\u578b<br> &nbsp; &nbsp;Class\u7c7b\u578b<br> &nbsp; &nbsp;\u6ce8\u89e3\u7c7b\u578b<br> &nbsp; &nbsp;\u679a\u4e3e\u7c7b\u578b<br> &nbsp; &nbsp;\u4ee5\u53ca\u4ee5\u4e0a\u7c7b\u578b\u7684\u6570\u7ec4\u5f62\u5f0f<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f:\u6ce8\u89e3\u4e0d\u5141\u8bb8\u7ee7\u627f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u89e3\u548c\u63a5\u53e3\u7684\u5173\u7cfb\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u89e3\u548c\u63a5\u53e3\u7684\u5b9a\u4e49\u90fd\u4f7f\u7528\u540c\u4e00\u4e2a\u5173\u952e\u5b57interface\uff0c\u800c\u4e14\u6ce8\u89e3\u4f53\u7684\u5b9a\u4e49\u4e5f\u975e\u5e38\u7c7b\u4f3c\u4e8e\u63a5\u53e3\u4e2d\u7684\u62bd\u8c61\u65b9\u6cd5\u3002\u56e0\u4e3a\u6ce8\u89e3\u672c\u8eab\u5c31\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u63a5\u53e3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u5c31\u662f\u8bf4\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5f53\u4f60\u4f7f\u7528&#8221;@interface&#8221;\u5173\u952e\u5b57\u5b9a\u4e49\u4e00\u4e2a\u6ce8\u89e3\u7c7b\u578b\u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u5b9e\u73b0<strong>java.lang.annotation.Annotation\u63a5\u53e3<\/strong>\uff0c\u5373\u4f7f\u4f60\u6ca1\u6709\u663e\u5f0f\u5730\u58f0\u660e\u8fd9\u4e2a\u7ee7\u627f\u5173\u7cfb\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u4f7f\u7528&#8221;interface&#8221;\u5173\u952e\u5b57\u5b9a\u4e49\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\uff0c\u5e76\u663e\u5f0f\u5730\u8ba9\u5b83\u7ee7\u627f<strong>java.lang.annotation.Annotation\u63a5\u53e3<\/strong>\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b0\u63a5\u53e3\u4e5f\u4e0d\u4f1a\u88ab\u89c6\u4e3a\u4e00\u4e2a\u6ce8\u89e3\u7c7b\u578b\u3002<\/li>\n\n\n\n<li><strong>java.lang.annotation.Annotation\u63a5\u53e3<\/strong>\u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u6ce8\u89e3\u7c7b\u578b\uff0c\u5b83\u53ea\u662f\u4e00\u4e2a\u666e\u901a\u7684\u63a5\u53e3\u7c7b\u578b\u3002<\/li>\n\n\n\n<li><strong>\u6ce8\u89e3\u7c7b\u578b\u5e76\u4e0d\u80fd\u663e\u5f0f\u5730\u7ee7\u627f\u5176\u4ed6\u7c7b\u6216\u63a5\u53e3\uff0c\u867d\u7136\u5b83\u786e\u5b9e\u9690\u5f0f\u5b9e\u73b0\u4e86\u63a5\u53e3java.lang.annotation.Annotation~<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136\uff0c\u4ee5\u4e0a\u6982\u5ff5\u4e86\u89e3\u5373\u53ef\u3002\u867d\u7136\u6ce8\u89e3\u548c\u63a5\u53e3\u786e\u5b9e\u5171\u4eab\u4e86\u540c\u4e00\u4e2a\u5173\u952e\u5b57\uff0c\u4f46\u5b83\u4eec\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u5177\u6709\u4e0d\u540c\u7684\u76ee\u7684\u548c\u529f\u80fd\uff0c\u53ef\u8c13\u5343\u5dee\u4e07\u522b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5143\u6ce8\u89e3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5143\u6ce8\u89e3\uff1a\u63cf\u8ff0\u4fee\u9970\u6ce8\u89e3\u7684\u6ce8\u89e3\uff08\u6ce8\u89e3\u7684\u6ce8\u89e3\uff09<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/larkdrop.cafe\/wp-content\/uploads\/2026\/04\/image-20230817180042910.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"494\" height=\"175\" data-original=\"https:\/\/larkdrop.cafe\/wp-content\/uploads\/2026\/04\/image-20230817180042910.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-160\"  sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e38\u7528\u5143\u6ce8\u89e3\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>@Retention\u5143\u6ce8\u89e3\uff0c\u6765\u5b9a\u4e49\u6211\u4eec\u81ea\u5df1\u5b9a\u4e49\u7684\u6ce8\u89e3\u7684\u4fdd\u7559\u7ea7\u522b.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>RetentionPolicy.RUNTIME \uff08\u8fd0\u884c\u65f6\u6709\u6548\uff09<\/li>\n\n\n\n<li>RetentionPolicy.CLASS \uff08\u5b57\u8282\u7801\u4e2d\u6709\u6548\uff09 \u9ed8\u8ba4<\/li>\n\n\n\n<li>RetentionPolicy.SOURCE \uff08\u6e90\u4ee3\u7801\u4e2d\u6709\u6548\uff09<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>@Target\u5143\u6ce8\u89e3\uff0c\u6ce8\u89e3\u53ef\u4ee5\u4f5c\u7528\u7684\u76ee\u6807<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u6ce8\u89e3\u800c\u8a00\uff0c\u53ef\u4ee5\u4f5c\u7528\u7684\u76ee\u6807\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6574\u4e2a\u7c7b ElementType.TYPE<\/li>\n\n\n\n<li>\u6210\u5458\u53d8\u91cf ElementType.FIELD<\/li>\n\n\n\n<li>\u6784\u9020\u65b9\u6cd5 ElementType.CONSTRUCTOR<\/li>\n\n\n\n<li>\u6210\u5458\u65b9\u6cd5 ElementType.METHOD<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e86\u89e3\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">@Inherited\u5143\u6ce8\u89e3\uff0c\u5982\u679c\u4e00\u4e2a\u7c7b\u7528\u4e0a\u4e86@Inherited\u4fee\u9970\u7684\u6ce8\u89e3\uff0c\u90a3\u4e48\u5176\u5b50\u7c7b\u4e5f\u4f1a\u7ee7\u627f\u8fd9\u4e2a\u6ce8\u89e3<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">@Document\u5143\u6ce8\u89e3\uff0c\u5982\u679c\u4e00\u4e2a\u6ce8\u89e3<code>@B<\/code>\uff0c\u88ab<code>@Documented<\/code>\u6807\u6ce8\uff0c\u90a3\u4e48\u88ab<code>@B<\/code>\u4fee\u9970\u7684\u7c7b\uff0c\u751f\u6210\u6587\u6863\u65f6\uff0c\u4f1a\u663e\u793a<code>@B<\/code>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6ce8\u89e3\u7684\u4f7f\u7528<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7c7b\u6bd4\u7c7b\u5bf9\u8c61<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">User user = new User(\"zs\",20);<br>User user2 = new User();<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u7684\u65f6\u5019\u6ce8\u89e3\u9700\u8981\u901a\u8fc7@\u7b26\u53f7\u8fdb\u884c\u5b9e\u4f8b\u5316, \u5bf9\u6bcf\u4e2a\u5c5e\u6027\u90fd\u8981\u8d4b\u503c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@\u6ce8\u89e3\u540d(\u5c5e\u60271=\u5c5e\u6027\u503c,\u5c5e\u60272=\u5c5e\u6027\u503c)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u91ca\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>&#8220;@&#8221;\u53ef\u4ee5\u8ba4\u4e3a\u76f8\u5f53\u4e8e\u201cnew\u201d\u5173\u952e\u5b57\uff0c\u5fc5\u4e0d\u53ef\u5c11\u3002<\/li>\n\n\n\n<li>\u6ce8\u89e3\u76f8\u5f53\u4e8e\u7ed9Java\u4ee3\u7801\u6253\u4e0a\u4e00\u4e2a\u6807\u7b7e\uff0c\u6240\u4ee5\u5b83\u5fc5\u987b\u8981\u4fee\u9970Java\u4ee3\u7801\u7684\u4e00\u4e2a\u7ed3\u6784\u3002\u6bd4\u5982\u4fee\u9970\u4e00\u6574\u4e2a\u7c7b\uff0c\u4e00\u6574\u4e2a\u65b9\u6cd5\uff0c\u4e00\u4e2a\u6210\u5458\u53d8\u91cf\u7b49\u7b49\u3002<\/li>\n\n\n\n<li>\u5b9e\u4f8b\u5316\u6ce8\u89e3\u65f6\uff0c\u5fc5\u987b\u7ed9\u6ce8\u89e3\u7684\u5404\u4e2a\u5c5e\u6027\u8d4b\u503c\uff0c<strong>\u8d4b\u503c\u65b9\u5f0f\u662f\uff1a\u5c5e\u6027\u540d = \u5c5e\u6027\u503c<\/strong>\u3002\u5982\u679c\u662f\u6570\u7ec4\u7c7b\u578b\u7684\u6ce8\u89e3\u5c5e\u6027\uff0c\u7528&#8221;{}&#8221;\u8d4b\u503c\u3002\u5982\u679c\u6709\u591a\u4e2a\u5c5e\u6027\uff0c\u8d4b\u503c\u65f6\u7528&#8221;\uff0c&#8221;\u9694\u5f00\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u4e8b\u9879:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6bcf\u4e2a\u5c5e\u6027\u90fd\u8981\u8d4b\u503c<\/li>\n\n\n\n<li>\u53ef\u4ee5\u4e0d\u8d4b\u503c,\u4f46\u662f\u8981\u6709\u9ed8\u8ba4\u503c, default<\/li>\n\n\n\n<li>\u6570\u7ec4\u5f62\u5f0f\u8d4b\u503c {}<\/li>\n\n\n\n<li>\u5982\u679c\u53ea\u67091\u4e2a\u5c5e\u6027, \u540d\u5b57\u53ebvalue, \u53ef\u4ee5\u7b80\u5316\u8d4b\u503c<\/li>\n\n\n\n<li>\u5982\u679c\u5c5e\u6027\u7c7b\u578b\u662f\u5f15\u7528\u7c7b\u578b, \u4e0d\u80fd\u662fnull<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u793a\u4f8b<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u200b<br>@MyAnnotation<br>public class Test {<br> &nbsp; &nbsp;@MyAnnotation(666)<br> &nbsp; &nbsp;int num;<br>\u200b<br> &nbsp; &nbsp;@MyAnnotation(value = 777, b = \"777\", c = {\"777\",\"aaa\",\"bb\"})<br> &nbsp; &nbsp;public void test() {<br> &nbsp;  }<br>}<br>\u200b<br>@interface MyAnnotation {<br> &nbsp; &nbsp;int value() default 123;<br>\u200b<br> &nbsp; &nbsp;String b() default \"abc\";<br>\u200b<br> &nbsp; &nbsp;String[] c() default {\"123\"};<br>}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6ce8\u89e3\u5904\u7406\u5668<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4ec0\u4e48\u662f\u6ce8\u89e3\u5904\u7406\u5668?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u83b7\u53d6\u6ce8\u89e3\u4fe1\u606f, \u6839\u636e\u6ce8\u89e3\u4fe1\u606f\u8fdb\u884c\u5904\u7406<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5982\u4f55\u83b7\u53d6\u6ce8\u89e3\u4fe1\u606f?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u6ce8\u89e3\u4fe1\u606f<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u57fa\u672c\u903b\u8f91<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u83b7\u53d6\u6ce8\u89e3\u6240\u52a0\u7684\u7c7b\u7684\u5bf9\u5e94\u7684Class\u5bf9\u8c61<\/li>\n\n\n\n<li>\u901a\u8fc7Class\u5bf9\u8c61\u83b7\u53d6\u6ce8\u89e3\u6240\u52a0\u7684\u7c7b\u4e2d\u7684\u7ed3\u6784(Filed, Constructor, Method)\u5bf9\u8c61<\/li>\n\n\n\n<li>\u901a\u8fc7\u8be5\u7ed3\u6784\u5bf9\u8c61\u5224\u65ad\u662f\u5426\u4f7f\u7528\u4e86\u6ce8\u89e3<\/li>\n\n\n\n<li>\u901a\u8fc7\u8be5\u7ed3\u6784\u5bf9\u8c61\u83b7\u53d6\u6ce8\u89e3\u5b9e\u4f8b<\/li>\n\n\n\n<li>\u901a\u8fc7\u6ce8\u89e3\u5b9e\u4f8b\u83b7\u53d6\u6ce8\u89e3\u5c5e\u6027\u4fe1\u606f<\/li>\n<\/ol>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-preformatted\">import java.lang.annotation.ElementType;<br>import java.lang.annotation.Retention;<br>import java.lang.annotation.RetentionPolicy;<br>import java.lang.annotation.Target;<br>import java.lang.reflect.Method;<br>\u200b<br>\u200b<br>public class Demo {<br> &nbsp; &nbsp;public static void main(String[] args) throws Exception{<br> &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u83b7\u53d6\u5b57\u8282\u7801\u6587\u4ef6\u5bf9\u8c61<br> &nbsp; &nbsp; &nbsp; &nbsp;Class&lt;?&gt; c = Class.forName(\"_24annotation.com.cskaoyan._04handle.Demo\");<br> &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u62ff\u5230\u65b9\u6cd5\u5bf9\u8c61<br> &nbsp; &nbsp; &nbsp; &nbsp;Method loginMethod = c.getDeclaredMethod(\"login\");<br> &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u5224\u65ad\u65b9\u6cd5\u4e0a\u662f\u5426\u4f7f\u7528\u4e86\u6ce8\u89e3<br> &nbsp; &nbsp; &nbsp; &nbsp;boolean annotationPresent = loginMethod.isAnnotationPresent(Login.class);<br> &nbsp; &nbsp; &nbsp; &nbsp;if (annotationPresent) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u83b7\u53d6\u6ce8\u89e3\u5b9e\u4f8b<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Login loginAnnotation = loginMethod.getAnnotation(Login.class);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u83b7\u53d6\u5c5e\u6027\u503c<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String password = loginAnnotation.password();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String username = loginAnnotation.username();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ \u6253\u5370<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(password);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(username);<br>\u200b<br> &nbsp; &nbsp; &nbsp;  }else {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(\"\u6ca1\u6709\u4f7f\u7528\u6ce8\u89e3\");<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;@Login<br> &nbsp; &nbsp;public static void login(){<br> &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp;  }<br>}<br>\u200b<br>\/\/ \u5b9a\u4e49\u6ce8\u89e3<br>@Retention(RetentionPolicy.RUNTIME)<br>@Target(ElementType.METHOD)<br>@interface Login{<br> &nbsp; &nbsp;\/\/ \u5c5e\u6027<br> &nbsp; &nbsp;String username() default \"admin\";<br>\u200b<br> &nbsp; &nbsp;String password() default \"123456\";<br>}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6ce8\u89e3\u7684\u4f7f\u7528\u573a\u666f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Java \u4e2d\uff0c\u6ce8\u89e3\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u591a\u79cd\u573a\u666f\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u7528\u4e8e\u6dfb\u52a0\u5143\u6570\u636e\u5230\u4ee3\u7801\u4e2d\u7684\u65b9\u5f0f\u3002\u6ce8\u89e3\u4e0d\u4f1a\u76f4\u63a5\u5f71\u54cd\u4ee3\u7801\u7684\u64cd\u4f5c\uff0c\u4f46\u53ef\u4ee5\u88ab\u5de5\u5177\u3001\u5e93\u548c\u6846\u67b6\u7528\u4e8e\u751f\u6210\u4ee3\u7801\u3001\u8fdb\u884c\u7f16\u8bd1\u65f6\u68c0\u67e5\u6216\u5728\u8fd0\u884c\u65f6\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 Java \u6ce8\u89e3\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7f16\u8bd1\u65f6\u68c0\u67e5<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u7528\u4e8e\u63d0\u9ad8\u4ee3\u7801\u8d28\u91cf\uff0c\u5982 <code>@Override<\/code> \u786e\u4fdd\u65b9\u6cd5\u8986\u76d6\uff0c<code>@Deprecated<\/code> \u8868\u793a\u65b9\u6cd5\u8fc7\u65f6\uff0c<code>@SuppressWarnings<\/code> \u6291\u5236\u7f16\u8bd1\u5668\u8b66\u544a\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6846\u67b6\u548c\u5e93<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>Web \u6846\u67b6\u5982 Spring \u4f7f\u7528\u6ce8\u89e3\u6765\u5b9a\u4e49\u8def\u7531\u3001\u8bf7\u6c42\u65b9\u6cd5\u3001\u4f9d\u8d56\u6ce8\u5165\u7b49\uff0c\u4f8b\u5982 <code>@Controller<\/code>, <code>@RequestMapping<\/code>, <code>@Autowired<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6d4b\u8bd5\u4ee3\u7801<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5355\u5143\u6d4b\u8bd5\u6846\u67b6\u5982 JUnit \u4f7f\u7528\u6ce8\u89e3\u5b9a\u4e49\u6d4b\u8bd5\u65b9\u6cd5\u3001\u6d4b\u8bd5\u524d\u540e\u7684\u64cd\u4f5c\uff0c\u4f8b\u5982 <code>@Test<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u4ee3\u7801\u751f\u6210<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u81ea\u52a8\u751f\u6210\u4ee3\u7801\uff0c\u5982 Lombok \u5e93\u4f7f\u7528 <code>@Getter<\/code>, <code>@Setter<\/code>, <code>@AllArgsConstructor<\/code> \u7b49\u6ce8\u89e3\u6765\u81ea\u52a8\u751f\u6210 getter\u3001setter \u65b9\u6cd5\u548c\u6784\u9020\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u914d\u7f6e\u548c\u8bbe\u7f6e<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5728 Spring \u548c\u5176\u4ed6\u4f9d\u8d56\u6ce8\u5165\u6846\u67b6\u4e2d\uff0c\u7528\u4e8e\u914d\u7f6e\u548c\u8bbe\u7f6e\u5e94\u7528\u7a0b\u5e8f\uff0c\u5982 <code>@Configuration<\/code>, <code>@Bean<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u62e6\u622a\u5668\u548c\u8fc7\u6ee4\u5668<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5728 AOP\uff08\u9762\u5411\u5207\u9762\u7f16\u7a0b\uff09\u4e2d\uff0c\u7528\u4e8e\u5b9a\u4e49\u5207\u70b9\u548c\u901a\u77e5\uff0c\u5982 <code>@Aspect<\/code>, <code>@Before<\/code>, <code>@After<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u81ea\u5b9a\u4e49\u4e1a\u52a1\u903b\u8f91<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u521b\u5efa\u81ea\u5b9a\u4e49\u6ce8\u89e3\u6765\u5b9e\u73b0\u7279\u5b9a\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u5982\u9a8c\u8bc1\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u7f13\u5b58\u7b49\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Java \u6ce8\u89e3\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u673a\u5236\u6765\u7b80\u5316\u4ee3\u7801\u3001\u590d\u7528\u4ee3\u7801\u3001\u63d0\u9ad8\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\uff0c\u5e76\u652f\u6301\u8bf8\u5982\u914d\u7f6e\u7ba1\u7406\u3001\u6570\u636e\u6821\u9a8c\u548c\u6846\u67b6\u5f00\u53d1\u7b49\u9ad8\u7ea7\u529f\u80fd\u3002\u901a\u8fc7\u6ce8\u89e3\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5c06\u5173\u952e\u4fe1\u606f\u5d4c\u5165\u5230\u4ee3\u7801\u7684\u58f0\u660e\u6027\u90e8\u5206\uff0c\u800c\u4e0d\u662f\u6267\u884c\u6027\u4ee3\u7801\u4e2d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Annotation\u5176\u5b9e\u662f\u4ee3\u7801\u91cc\u7684\u7279\u6b8a\u6807\u8bb0\uff0c\u8fd9\u4e9b\u6807\u8bb0\u53ef\u4ee5\u5728\u7f16\u8bd1\u3001\u7c7b\u52a0\u8f7d\u3001\u8fd0\u884c\u65f6\u88ab\u8bfb\u53d6\uff0c\u5e76\u6267\u884c\u76f8\u5e94\u7684\u5904\u7406 \u901a\u8fc7\u4f7f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-learn","tag-java"],"_links":{"self":[{"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":1,"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":161,"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/posts\/159\/revisions\/161"}],"wp:attachment":[{"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/larkdrop.cafe\/index.php\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}