{"id":876,"date":"2021-08-25T16:50:22","date_gmt":"2021-08-25T08:50:22","guid":{"rendered":"https:\/\/fireinsect.top\/?p=876"},"modified":"2021-08-26T13:50:00","modified_gmt":"2021-08-26T05:50:00","slug":"java%e6%b3%a8%e8%a7%a3%e7%90%86%e8%a7%a3%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/fireinsect.top\/index.php\/2021\/08\/25\/java%e6%b3%a8%e8%a7%a3%e7%90%86%e8%a7%a3%e7%ac%94%e8%ae%b0\/","title":{"rendered":"Java\u6ce8\u89e3\u7406\u89e3\u7b14\u8bb0"},"content":{"rendered":"\n<!--more-->\n\n\n\n<p>Java\u6ce8\u89e3\u672c\u8eab\u5c31\u662f\u4e00\u4e2a\u7c7b\uff0c\u8fd9\u4e2a\u7c7b\u7684\u4f5c\u7528\u5c31\u662f\u65b9\u4fbf\u5bf9\u4ee3\u7801\u8fdb\u884c\u81ea\u5b9a\u4e49\u7684\u8c03\u6574<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/style.youkeda.com\/img\/ham\/course\/j4\/service1.svg\" alt=\"\"\/><\/figure>\n\n\n\n<p>1\u3001@Target \u6307\u5b9a\u4e86\u8be5\u6ce8\u89e3\u7684\u9002\u7528\u8303\u56f4\uff0c\u56fe\u4e3a\u4f5c\u7528\u4e8e\u7c7b<\/p>\n\n\n\n<p>2\u3001@Retention \u6307\u5b9a\u4e86\u6ce8\u89e3\u7684\u751f\u547d\u5468\u671f<\/p>\n\n\n\n<p>3\u3001@Documented \u5c06\u6ce8\u89e3\u4e2d\u7684\u5143\u7d20\u5305\u542b\u5230JavaDoc\u6587\u6863\u4e2d<\/p>\n\n\n\n<p>4\u3001@interface \u8868\u660e\u6ce8\u89e3\u7684\u7c7b\u578b\u4e3aAnnotation<\/p>\n\n\n\n<p>5\u3001\u4e3aAnnotation\u5c5e\u6027\uff0c\u524d\u9762\u7684\u7c7b\u578b\u6307\u5b9a\u4e86\u5c5e\u6027\u7684\u7c7b\u578b\uff0c\u540e\u9762\uff08value\uff09\u6307\u5b9a\u4e86\u5c5e\u6027\u540d\u79f0\uff0cdefault\u8868\u793a\u9ed8\u8ba4\u503c\u540e\u9762\u7684\u201c\u201d \u8868\u793a\u9ed8\u8ba4\u503c\u4e3a\u65e0\u3002\u4e0a\u9762\u7684<strong>@AliasFor<\/strong>\u8868\u793a\u4e0b\u9762\u5c5e\u6027\u7684\u522b\u540d\u3002<\/p>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>1-1 <strong>@Target<\/strong>\u5b58\u5728<\/p>\n\n\n\n<p><strong> ElementType.TYPE\uff08\u4f5c\u7528\u4e8e\u7c7b\u3001\u63a5\u53e3\u7c7b\u3001\u679a\u4e3e\u7c7b\uff09<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\"><strong>@Service<\/strong>\n<strong>public<\/strong> <strong>class<\/strong> <strong>MessageServiceImpl<\/strong> <strong>implements<\/strong> <strong>MessageService<\/strong>{\n\n    <strong>public<\/strong> String <strong>getMessage<\/strong>() {\n         <strong>return<\/strong> \"Hello World!\";\n    }\n\n}<\/code><\/pre>\n\n\n\n<p> <strong>ElementType.FIELD(\u4f5c\u7528\u4e8e\u7c7b\u7684\u5c5e\u6027\u4e0a\uff09<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\"><strong>public<\/strong> <strong>class<\/strong> <strong>MessageServiceImpl<\/strong> <strong>implements<\/strong> <strong>MessageService<\/strong>{\n\n    <strong>@Autowired<\/strong>\n    <strong>private<\/strong> WorkspaceService workspaceService;\n\n}<\/code><\/pre>\n\n\n\n<p> <strong>ElementType.METHOD(\u4f5c\u7528\u4e8e\u7c7b\u7684\u65b9\u6cd5\u4e0a\uff09<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\"><strong>public<\/strong> <strong>class<\/strong> <strong>MessageServiceImpl<\/strong> <strong>implements<\/strong> <strong>MessageService<\/strong>{\n\n    <strong>@ResponseBody<\/strong>\n    <strong>public<\/strong> String <strong>getMessage<\/strong>() {\n         <strong>return<\/strong> \"Hello World!\";\n    }\n\n}<\/code><\/pre>\n\n\n\n<p> <strong>ElementType.PARAMETER(\u4f5c\u7528\u4e8e\u7c7b\u7684\u53c2\u6570\u4e0a\uff09<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"java\" class=\"language-java\"><strong>public<\/strong> <strong>class<\/strong> <strong>MessageServiceImpl<\/strong> <strong>implements<\/strong> <strong>MessageService<\/strong>{\n\n    <strong>public<\/strong> String <strong>getMessage<\/strong>(<strong>@RequestParam(\"msg\")<\/strong>String msg) {\n         <strong>return<\/strong> \"Hello \"+msg;\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>\u540c\u65f6\u4f5c\u7528\u7528\u9017\u53f7\u9694\u5f00<\/p>\n\n\n\n<p>2-1<strong>@Retention<\/strong>\u7684<strong>RetentionPolicy\u503c<\/strong>\u5b58\u5728\uff1a<\/p>\n\n\n\n<p>SOURCE\uff08\u7eaf\u6ce8\u91ca\u4f5c\u7528\uff09<\/p>\n\n\n\n<p>CLASS\uff08\u7f16\u8bd1\u9636\u6bb5\u6709\u6548\uff09<\/p>\n\n\n\n<p>RUNTIME\uff08\u8fd0\u884c\u65f6\u6709\u6548\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-876","post","type-post","status-publish","format-standard","hentry","category-4"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/876"}],"collection":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/comments?post=876"}],"version-history":[{"count":3,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/876\/revisions"}],"predecessor-version":[{"id":885,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/876\/revisions\/885"}],"wp:attachment":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/media?parent=876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/categories?post=876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/tags?post=876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}