{"id":2696,"date":"2022-01-03T11:35:43","date_gmt":"2022-01-03T03:35:43","guid":{"rendered":"https:\/\/ufqi.com\/blog\/?p=2696"},"modified":"2025-02-10T07:55:08","modified_gmt":"2025-02-09T23:55:08","slug":"gwa2-java-annotations","status":"publish","type":"post","link":"https:\/\/ufqi.com\/blog\/gwa2-java-annotations\/","title":{"rendered":"\u4e24\u4e2a\u5b9e\u4f8b\u89e3\u91ca\u6e05\u695aJava Annotations\u6ce8\u89e3"},"content":{"rendered":"\n<p>Java Annotations\u6ce8\u89e3\u548cJava Comments\u6ce8\u91ca\uff0c\u82f1\u6587\u91cc\u5dee\u522b\u5f88\u5927\uff0c\u5728\u4e2d\u6587\u4e2d\u4e00\u5b57\u4e4b\u5dee\u8ba9\u4eba\u9887\u4e3a\u8d39\u89e3\u3002Java Comments\u6ce8\u91ca\u662f\u968f\u7740Java\u8bed\u8a00\u7684\u8bde\u751f\u5c31\u6709\u7684\uff0c\u610f\u4e49\u660e\u786e\uff0c\u7b80\u5355\u6613\u61c2\uff0c\u5c31\u662f\u5728\u6e90\u4ee3\u7801\u4e2d\u7684\u89e3\u91ca\u4fe1\u606f\uff0c\u901a\u5e38\u7528\u5728\u5e2e\u52a9\u4ee3\u7801\u7f16\u5199\u4eba\u5458\u7406\u89e3\u4ee3\u7801\u3002Java Annotations\u51fa\u73b0\u7684\u8f83\u665a\uff0c\u5728Java 1.5\uff08Java 5\uff09\u4e2d\u624d\u5f15\u5165\uff0c\u76ee\u524d\uff082022\u5e74\uff09Java\u90e8\u7f72\u7684\u4e3b\u6d41\u662fJava 8\uff08Java 1.8\uff09\uff0c\u6700\u65b0\u53d1\u884c\u7248\u662fJava 11\uff08Java 1.11\uff09.<\/p>\n\n\n\n<p>\u4f46Java Annotations\u6ce8\u89e3\u7684\u610f\u4e49\u548c\u4f5c\u7528\u5c31\u663e\u5f97\u6709\u4e9b\u8d39\u89e3\uff0c\u6bd4\u5982\u5b98\u65b9\u6587\u6863\u4e2d\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Annotations do not directly affect program semantics, but they do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time.<\/p><p>Annotations\u6ce8\u89e3\u4e0d\u4f1a\u76f4\u63a5\u5f71\u54cd\u7a0b\u5e8f\u7684\u8bed\u4e49\uff0c\u4f46\u662f\u4ed6\u4eec\u786e\u5b9e\u5f71\u54cd\u5de5\u5177\u548c\u5e93\u5904\u7406\u7a0b\u5e8f\u7684\u65b9\u5f0f\uff0c\u8fdb\u800c\u5f71\u54cd\u8fd0\u884c\u4e2d\u7684\u7a0b\u5e8f\u7684\u8bed\u4e49\u3002Annotations\u6ce8\u89e3\u53ef\u4ee5\u4ece\u6e90\u6587\u4ef6 \uff0cclass\u6587\u4ef6\uff0c\u6216\u8005\u8fd0\u884c\u65f6\u7684\u53cd\u5c04\u4e2d\u8bfb\u53d6\u3002<\/p><\/blockquote>\n\n\n\n<p>\u968f\u7740\u201c\u5de5\u5177\u548c\u5e93\u5904\u7406\u7a0b\u5e8f\u201d\u7684\u6d41\u884c\uff0c\u6bd4\u5982\u5728Java\u5f00\u53d1\u4e2d\u9010\u6e10\u6d41\u884c\u7684Spring\u5168\u5bb6\u6876\u7b49\uff0c\u5904\u5904\u53ef\u89c1\u7684@RequestXXX \u7b49\u8868\u8ff0\uff0c\u8ba9\u540e\u751fJava Annotations\u9010\u6e10\u8d70\u5165\u5f00\u53d1\u8005\u7684\u89c6\u91ce\u3002\u7136\u5219\u53ea\u8a00\u7247\u8bed\u5730\u8981\u89e3\u91ca\u6e05\u695aJava Annotations\u6ce8\u89e3\u662f\u4ec0\u4e48\u4e1c\u897f\u53ca\u600e\u4e48\u4f5c\u7528\u6216\u8005\u5de5\u4f5c\u7684\uff0c\u5374\u975e\u6613\u4e8b\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u6240\u4e3b\u5bfc\u7684Java \u5f00\u53d1\u6846\u67b6GWA2 in Java( &nbsp;https:\/\/ufqi.com\/dev\/gwa2\/ )\u5e76\u6ca1\u6709\u8fc7\u591a\u5730\u501a\u91cdJava Annotations\u6ce8\u89e3\uff0c\u4e3b\u8981\u662f\u5728\u521d\u671f\u6280\u672f\u67b6\u6784\u9009\u578b\u65f6\uff0c\u6211\u4eec\u8003\u5bdf\u4e86\u4f7f\u7528Reflection\u7b49\u76f8\u5173\u6280\u672f\u65f6\uff0c\u53d1\u73b0\u5176\u6027\u80fd\u4f1a\u4e0b\u964d\u5b89\u5168\u53d7\u5f71\u54cd\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Due to 1) issues of performance and security of java.lang.reflection, We do not use it as routing or dynamic module invoking at present.<\/p><cite>\u9274\u4e8eReflection\u76f8\u5173\u6280\u672f\u5b58\u5728\u6027\u80fd\u548c\u5b89\u5168\u76f8\u5173\u65b9\u9762\u95ee\u9898\uff0cGWA2 in Java \u76ee\u524d\u6ca1\u6709\u8003\u8651\u5c06\u5176\u4f5c\u4e3a\u8def\u7531\u548c\u52a8\u6001\u6a21\u5757\u52a0\u8f7d\u6280\u672f\u624b\u6bb5\u3002<\/cite><\/blockquote>\n\n\n\n<p>\u7136\u800c\uff0cJava\u5f00\u53d1\u4e1a\u754c\u4f3c\u4e4e\u5f62\u6210\u4e86\u4e00\u79cd\u7ad9\u5728\u201c\u5de8\u4eba\u80a9\u8180\u201d\u4e0a\u642d\u79ef\u6728\u5f0f\u5730\u7684\u5806\u53e0\uff0c\u7b2c\u4e00\u4e2a\u6263\u5b50\u6b6a\u4e86\u5927\u5bb6\u4e5f\u5c31\u4e00\u987a\u6e9c\u5730\u7ee7\u7eed\u6b6a\u4e0b\u53bb\uff0c\u6240\u8c13\u6027\u80fd\u548c\u5b89\u5168\u95ee\u9898\u90fd\u662f\u53ef\u4ee5\u514b\u670d\u7684\uff0c\u4e0d\u80fd\u89e3\u51b3\u7684\u90e8\u5206\u4e5f\u662f\u5728\u53ef\u63a5\u53d7\u8303\u56f4\u5185\uff0c\u7686\u5927\u6b22\u559c\u3002<br \/>\u8fd1\u671f\u6211\u4eec\u63a5\u624b\u4e86\u4e24\u4e2aJava\u5f00\u53d1\u7684\u4e8c\u671f\u9879\u76ee\uff0c\u57fa\u4e8eJava Spring\u5168\u5bb6\u6876\uff0c\u9879\u76ee\u6280\u672f\u6808\u867d\u7136\u662fJava\uff0c\u4f46\u5176\u6240\u4f9d\u8d56\u7684\u5404\u79cd\u7b2c\u4e09\u65b9\u7ec4\u4ef6\u8fbe\u5230\u4ee4\u4eba\u773c\u82b1\u7f2d\u4e71\u7684\u5730\u6b65\uff08\u5982\u4e0b\u56fe\uff09\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2022\/01\/java-spring-arch.png\"><img loading=\"lazy\" width=\"651\" height=\"438\" src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2022\/01\/java-spring-arch.png\" alt=\"\" class=\"wp-image-2697\" srcset=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2022\/01\/java-spring-arch.png 651w, https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2022\/01\/java-spring-arch-300x202.png 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><figcaption>Java Spring \u7ec4\u4ef6\u5957\u7cfb<\/figcaption><\/figure>\n\n\n\n<p>\u65e2\u7136Java Annotations\u5982\u6b64\u91cd\u8981\uff0c\u81ea\u7136\u8981\u5f04\u6e05\u695a\uff0c\u7136\u800c\u5f53\u6211\u4eec\u8bd5\u56fe\u5411\u4e00\u4e9b\u5de5\u7a0b\u5e08\u89e3\u91caJava Annotations\u662f\u4ec0\u4e48\u3001\u600e\u4e48\u6837\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u5e76\u4e0d\u5bb9\u6613\uff0c\u4e00\u65b9\u9762\u662fJava\u8bed\u8a00\u672c\u8eab\u7684\u590d\u6742\u6027\uff0c\u53e6\u4e00\u65b9\u9762\u662fAnnotations\u662f\u4e0a\u5c42\u5e94\u7528\uff0c\u662f\u53ef\u9009\u9879\u3002\u7ecf\u8fc7\u4e00\u756a\u641c\u7d22\u3001\u601d\u8003\u548c\u63a2\u7a76\uff0c\u6211\u89c9\u5f97\u5982\u4e0b\u4e24\u4e2a\u5b9e\u4f8b\u53ef\u4ee5\u6e05\u6670\u5730\u89e3\u91caJava Annotations\u6ce8\u89e3\u7684\u57fa\u672c\u539f\u7406\u548c\u5e94\u7528\u5b9e\u8df5\uff0c\u56de\u7b54\u4e86Java Annotations\u6ce8\u89e3\u662f\u4ec0\u4e48\uff0c\u4e3a\u4ec0\u4e48\u548c\u600e\u4e48\u6837\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p><strong>\u5b9e\u4f8b1. \u7528Java Annotations\u6ce8\u89e3\u6807\u8bb0\u67d0\u4e2a\u5bf9\u8c61\u7c7b\u3001\u5b9e\u4f8b\u3001\u65b9\u6cd5\u548c\u5c5e\u6027\u5177\u6709\u6216\u4e0d\u5177\u6709\u67d0\u4e2a\u5c5e\u6027\u3002<\/strong><\/p>\n\n\n\n<p>\u8fd9\u4e2a\u5b9e\u4f8b\u6765\u81ea\u5b98\u7f51 \uff08 https:\/\/docs.oracle.com\/javase\/1.5.0\/docs\/guide\/language\/annotations.html \uff09<\/p>\n\n\n\n<p>e.g.1.1. SampleTestTag.java: \u81ea\u5b9a\u4e49\u4e00\u4e2aJava Annotation\u6ce8\u89e3\u5bf9\u8c61\uff0c\u5176\u4e2d\u7684  @Retention \u548c @Target \u662f\u6ce8\u89e3\u7684\u6ce8\u89e3\uff0c\u79f0\u4e4b\u4e3a\u201c\u5143\u6ce8\u89e3\u201d\uff0c \u6ce8\u89e3\u7c7b\u7684\u4ec0\u4e48\u662f\u5728\u540d\u79f0\u524d\u52a0 \u201c@\u201d at\u7b26\u53f7 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.lang.annotation.*;\n\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.METHOD)\npublic @interface SampleTestTag { \n\n}<\/code><\/pre>\n\n\n\n<p>e.g.1.2. FooBar.java: \u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u7c7b FooBar \uff0c \u4f7f\u7528\u4e0a\u9762\u521b\u5efa\u7684Java\u6ce8\u89e3 SampleTestTag<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public class FooBar {\n    @SampleTestTag public static void m1() { }\n    public static void m2() { }\n    @SampleTestTag public static void m3() {\n        throw new RuntimeException(\"Boom\");\n    }\n    public static void m4() { }\n    @SampleTestTag public static void m5() { }\n    public static void m6() { }\n    @SampleTestTag public static void m7() {\n        throw new RuntimeException(\"Crash\");\n    }\n    public static void m8() { }\n}<\/pre>\n\n\n\n<p>e.g.1.3. FooBarTest.java: \u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u7a0b\u5e8f\uff0c\u8c03\u7528\u5bf9\u8c61\u7c7b FooBar, \u6d4b\u8bd5 SampleTestTag \u7684\u533a\u5206\u4f5c\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.lang.reflect.*;\n\npublic class FooBarTest {\n   public static void main(String&#091;] args) throws Exception {\n      int passed = 0, failed = 0;\n      for (Method m : Class.forName(args&#091;0]).getMethods()) {\n         if (m.isAnnotationPresent(SampleTestTag.class)) {\n            try {\n               m.invoke(null);\n               passed++;\n            } catch (Throwable ex) {\n               System.out.printf(\"Test %s failed: %s %n\", m, ex.getCause());\n               failed++;\n            }\n         }\n      }\n      System.out.printf(\"Passed: %d, Failed %d%n\", passed, failed);\n   }\n}<\/code><\/pre>\n\n\n\n<p>\u8be5\u6d4b\u8bd5\u7a0b\u5e8f\u9884\u671f\u8fd0\u884c\u7684\u7ed3\u679c\u5927\u81f4\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java FooBarTest FooBar\nTest public static void Foo.m3() failed: java.lang.RuntimeException: Boom \nTest public static void Foo.m7() failed: java.lang.RuntimeException: Crash \nPassed: 2, Failed 2<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u5b9e\u4f8b\u8868\u793a\uff0c\u901a\u8fc7\u81ea\u5b9a\u4e49\u4e00\u4e2a\u6ce8\u89e3\uff0c\u53ef\u4ee5\u5c06\u5bf9\u8c61\u7c7b\u7684\u67d0\u4e9b\u65b9\u6cd5\u6807\u8bb0\u51fa\u6765\uff0c\u6838\u5fc3\u65b9\u6cd5\u662fisAnnotationPresent\u3002 \u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u4f8b\uff0c\u5982\u679c\u8fd9\u4e2a\u8def\u5b50\u8d70\u5f97\u901a\uff0c\u6709\u8fd9\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\u6216\u8303\u5f0f\uff0c\u53ef\u4ee5\u5c06\u5bf9\u8c61\u7c7b\u3001\u5b9e\u4f8b\u3001\u65b9\u6cd5\u548c\u5c5e\u6027\u8fdb\u884c\u5206\u7c7b\uff0c\u4eff\u4f5b\u6253\u5f00\u4e86\u6f58\u591a\u62c9\u7684\u76d2\u5b50\uff0c\u8d4b\u4e88\u5f00\u53d1\u8005\u65e0\u7a77\u5c3d\u7684\u5206\u7c7b\u80fd\u529b\u3002<br \/>\u5f53\u5177\u5907\u8fd9\u79cd\u80fd\u529b\u540e\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u6839\u636e\u5206\u7c7b\uff0c\u8ba9A\u7c7b\u7684\u8fd0\u884c\uff0c\u8ba9B\u7c7b\u7684\u90fd\u7184\u706b\uff1b\u5728\u82f1\u56fd\u533a\u8fd0\u884cA\u7c7b\uff0c\u5728\u5317\u7f8e\u8fd0\u884cB\u7c7b\uff1b\u8ba9VIP\u7684\u8fd0\u884cA\u7c7b\uff0c\u8ba9\u975eVIP\u7684\u8fd0\u884cB\u7c7b\uff1b\u8ba9\u5c0f\u5b69\u770bA\u7c7b\uff0c\u8ba9\u8001\u4eba\u770bB\u7c7b\uff0c\u5176\u4ed6\u4eba\u770bC\u7c7b&#8230;.<\/p>\n\n\n\n<p>\u663e\u7136\u8fd9\u79cd\u80fd\u529b\u662f\u5f3a\u5927\u7684\uff0c\u4f46\u540c\u65f6\u5176\u590d\u6742\u6027\u4e5f\u663e\u73b0\u51fa\u6765\u4e86\uff0c\u5f00\u53d1\u8005\u770b\u5230\u7684\u4ee3\u7801\u548c\u6700\u7ec8\u8fd0\u884c\u65f6\u7684\u4ee3\u7801\u53ef\u80fd\u9ad8\u5ea6\u7684 \u4e0d&#8211;\u4e00&#8211;\u81f4\u3002 \u5c3d\u7ba1\u4ee3\u7801\u90fd\u6446\u5728\u54ea\u91cc\uff0c\u4f46\u5177\u4f53\u8dd1\u90a3\u4e9b\u4ee3\u7801\u9700\u8981\u770b\u8fd0\u884c\u65f6\u7684\u72b6\u6001\u3002\u7531\u6b64\u9020\u6210\u4e86\u53ef\u6015\u7684\u6240\u89c1\u975e\u6240\u5f97\u3002<\/p>\n\n\n\n<p><strong> \u5b9e\u4f8b2. \u7528Java Annotations\u6ce8\u89e3\u6807\u8bb0\u67d0\u4e2a\u5bf9\u8c61\u7c7b\u3001\u5b9e\u4f8b\u3001\u65b9\u6cd5\u548c\u5c5e\u6027\u5177\u6709\u67d0\u4e2a\u5c5e\u6027\u7684\u67d0\u79cd\u8d4b\u503c\u3002 <\/strong><\/p>\n\n\n\n<p>\u8fd9\u662f\u5bf9\u5b9e\u4f8b1\u7684\u8fdb\u5316\u548c\u5347\u7ea7\uff0c\u5982\u679c\u5b9e\u4f8b1\u63d0\u4f9b\u8ba9\u67d0\u4e2a\u5bf9\u8c61\u5177\u6709\u6216\u4e0d\u5177\u6709\uff0c\u662f\u4e0e\u975e\u7684\u7b80\u5355\u4e8c\u5143\u5206\u7c7b\uff0c\u5219\u5b9e\u4f8b2\u5c06\u8fd9\u79cd\u80fd\u529b\u65e0\u9650\u5347\u7ea7\u5230\u8ba9\u67d0\u4e2a\u5bf9\u8c61\u7684\u62e5\u6709\u67d0\u4e2a\u5c5e\u6027\uff0c\u800c\u4e14\u8fd9\u4e2a\u5c5e\u6027\u7684\u8d4b\u503c\u53ef\u4ee5\u5343\u53d8\u4e07\u5316\u3002<br \/>\u5927\u767d\u8bdd\u5c31\u662f\u6ce8\u89e3\u53ef\u4ee5\u5e26\u53c2\u6570\u4e86\uff0c\u8fd9\u51e0\u4e4e\u8981\u5f00\u4e00\u5f00\u8111\u6d1e\u624d\u597d\u7406\u89e3\uff0c\u7ed3\u5408\u4e0b\u9762\u8fd9\u4e2a\u5b9e\u4f8b\u3002\uff08 https:\/\/www.educba.com\/java-annotations\/ \uff09<\/p>\n\n\n\n<p>e.g.2.1. MagicianAnnotation.java: \u81ea\u5b9a\u4e49\u4e00\u4e2a\u6ce8\u89e3\u7c7b\uff0c\u8be5\u6ce8\u89e3\u5e26\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u7ed9\u4e86\u7f3a\u7701\u9ed8\u8ba4\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target({ElementType.TYPE, ElementType.METHOD})\n@Retention(RetentionPolicy.RUNTIME)\npublic @interface MagicianAnnotation {\n    String Wizard() default \"Reynolds\";\n    String House() default \"Green\";\n}\n\n<\/code><\/pre>\n\n\n\n<p>e.g.2.2. MagicianObject.java: \u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u7c7b\uff0c\u4f7f\u7528MagicianAnnotation\u4fee\u9970\uff0c\u8be5\u5bf9\u8c61\u7c7b\u6709\u4e00\u4e2a\u65b9\u6cd5 getString\uff0c getString\u4e5f\u4f7f\u7528\u6ce8\u89e3MagicianAnnotation\u8fdb\u884c\u4fee\u9970\uff0c\u4e14\u5e26\u6709\u4e24\u4e2a\u53c2\u6570<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@MagicianAnnotation\npublic class MagicianObject {\n    @MagicianAnnotation(Wizard = \"Harry Potter\", House = \"Red\")\n    public String getString()  {  return null; }\n}<\/code><\/pre>\n\n\n\n<p>e.g.2.3. MagicianTest.java: \u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u7c7b\uff0c\u8fd0\u884cMagicianObject, \u89c2\u6d4b\u88abMagicianAnnotation\u6240\u4fee\u9970\u7684\u60c5\u51b5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.lang.annotation.Annotation;\nimport java.lang.reflect.AnnotatedElement;\nimport java.lang.reflect.Method;\n\npublic class MagicianObjectTest {\n\t\n\tpublic static void main(String&#091;] args) throws NoSuchMethodException, SecurityException {\n\t\tnew MagicianObject();\n\t\tClass&lt;Magician&gt; magic = MagicianObject.class;\n\t\treadAnnotationOn(magic);\n\t\tMethod method = magic.getMethod(\"getString\", new Class&#091;]{});\n\t\treadAnnotationOn(method);\n\t}\n\t\n\tstatic void readAnnotationOn(AnnotatedElement element){\n\t\ttry{\n\t\t\tSystem.out.println(\"\\n Find annotations on \" + element.getClass().getName());\n\t\t\tAnnotation&#091;] annotations = element.getAnnotations();\n\t\t\tfor (Annotation annotation : annotations){\n\t\t\t\tif (annotation instanceof MagicianAnnotation){\n\t\t\t\t\tMagicianAnnotation mData = (MagicianAnnotation) annotation;\n\t\t\t\t\tSystem.out.println(\"Wizard Name :\" + mData.Wizard() + \" , House Color :\" + mData.House());\n\t\t\t\t}\n\t\t\t}\n\t\t} \n\t\tcatch (Exception e){\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<p> \u8be5\u6d4b\u8bd5\u7a0b\u5e8f\u9884\u671f\u8fd0\u884c\u7684\u7ed3\u679c\u5927\u81f4\u4e3a\uff1a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java MagicianObjectTest \nFind annotations on java.lang.Class\nWizard Name :Reynolds , House Color :Green\n\nFind annotations on java.lang.reflect.Method\nWizard Name :Harry Potter , House Color :Red<\/code><\/pre>\n\n\n\n<p>\u5b9e\u4f8b2\u8868\u660e\uff0c\u5f15\u5165\u4e86\u81ea\u5b9a\u4e49\u7684\u6ce8\u89e3\u4e4b\u540e\uff0c\u5728\u539f\u4ee3\u7801\u5c42\u9762\u7684\u6ce8\u89e3\u53ca\u5176\u5c5e\u6027\u3001\u8d4b\u503c\u7b49\uff0c\u6700\u7ec8\u4f1a\u5728\u8fd0\u884c\u65f6\u5206\u522b\u8bfb\u53d6\u5230\uff0c\u4f9d\u636e\u8fd9\u4e9b\u8bbe\u7f6e\u3001\u914d\u7f6e\u7684\u5c5e\u6027\u53ca\u8d4b\u503c\uff0c\u540c\u6837\u7684\u4ee3\u7801\u53ef\u80fd\u4f1a\u4ea7\u751f\u5343\u53d8\u4e07\u5316\u7684\u8fd0\u884c\u7ed3\u679c\u3002<br \/>\u8fd9\u79cd\u9b54\u6cd5\u867d\u7136\u8d4b\u4e88\u4e86\u5f00\u53d1\u8005\u4e30\u5bcc\u7684\u6280\u80fd\uff0c\u5374\u4e5f\u4e3a\u7a0b\u5e8f\u7684\u8ffd\u8e2a\u8bbe\u7f6e\u4e86\u9677\u9631\uff0c\u6b63\u5982\u6211\u4eec\u5728\u5404\u79cdJava\u5f00\u53d1\u624b\u518c\uff08 https:\/\/ufqi.com\/news\/ulongpage.1510.html?tit=Java\u958b\u767c\u624b\u518a-\u963f\u91cc\u5df4\u5df4-\u5d69\u5c71\u7248-3:\u5e38\u91cf\u5b9a\u4e49 \uff09\u4e2d\uff0c\u90fd\u6566\u6566\u6559\u8bf2\u4e0d\u8981\u5728\u7a0b\u5e8f\u6e90\u4ee3\u7801\u4e2d\u7559\u7f6e\u201c\u9b54\u6cd5\u201d\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u3010\u5f3a\u5236\u3011\u4e0d\u5141\u8bb8\u4efb\u4f55\u9b54\u6cd5\u503c\uff08\u5373\u672a\u7ecf\u9884\u5148\u5b9a\u4e49\u7684\u5e38\u91cf\uff09\u76f4\u63a5\u51fa\u73b0\u5728\u4ee3\u7801\u4e2d\u3002<\/p><\/blockquote>\n\n\n\n<p>\u6240\u4ee5\uff0c\u672c\u610f\u4e0a\u7406\u89e3\uff0cJava Annotation\u6ce8\u89e3\u662f\u5bf9\u6ce8\u91ca\u7684\u4e30\u5bcc\u548c\u6269\u5c55\uff0c\u5b83\u7684\u8fb9\u754c\u4e0d\u5e94\u8be5\u6269\u5c55\u5230\u5f71\u54cd\u7a0b\u5e8f\u8fd0\u884c\u903b\u8f91\u4e0a\u53bb\uff0c\u6ce8\u89e3\u7684\u6839\u672c\u4ecd\u7136\u662f\u50cf\u5185\u7f6e\u7684\u90a3\u51e0\u4e2a\u4f5c\u7528\u90a3\u6837\uff08 &nbsp;@Override, @Deprecated, @SuppressWarnings\u7b49\u7b49 \uff09\uff0c\u662f\u5e2e\u52a9\u7406\u89e3\u4ee3\u7801\uff0c\u800c\u4e0d\u662f\u4fee\u6539\u53d8\u66f4\u3001\u8def\u7531\u5bfc\u5411\u7a0b\u5e8f\u4e1a\u52a1\u903b\u8f91\u672c\u8eab\u3002<br \/>\u4ece\u8fd9\u4e2a\u610f\u4e49\u4e0a\u6765\u8bf4\uff0cJava Spring\u5168\u5bb6\u6876\u7b49\u5251\u8d70\u504f\u950b\u4f3c\u4e4e\u8d70\u5f97\u6709\u4e9b\u8fdc\u4e86\u3002<\/p>\n\n\n\n<p>\u56de\u5230\u8d77\u521d\uff0c\u5e0c\u671b\u8fd9\u4e24\u4e2a\u5b9e\u4f8b\u80fd\u591f\u6e05\u695a\u7684\u89e3\u91ca\u4e86Java Annotations\u6ce8\u89e3\u7684\u6765\u9f99\u53bb\u8109\uff0c\u5982\u540c\u83dc\u5200\u53ef\u4ee5\u5207\u83dc\u4e5f\u53ef\u4ee5\u6740\u4eba\u4e00\u6837\uff0c\u6ce8\u89e3\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u7406\u89e3\u4ee3\u7801\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7Reflect\u53cd\u5c04\u6280\u672f\u5bf9\u7a0b\u5e8f\u7684\u8fd0\u884c\u903b\u8f91\u8fdb\u884c\u4fee\u6539\u53d8\u66f4\u3001\u8def\u7531\u5bfc\u5411\u7b49\u7b49\u3002\u7406\u89e3\u4e86\u8fd9\u4e9b\uff0c\u518d\u53bb\u770bJava Spring\u6846\u67b6\u4e2d\u7684 @RequestXXX \u5c31\u4f1a\u8c41\u7136\u5f00\u6717\uff0c\u4e0d\u8fc7\u5c3d\u7ba1\u77e5\u9053\u4e86\u57fa\u672c\u539f\u7406\uff0c\u8981\u5f04\u6e05\u695a\u6bcf\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u6ce8\u89e3\u7684\u5177\u4f53\u542b\u4e49\uff0c\u8fd8\u9700\u8981\u8fdb\u4e00\u6b65\u5730\u89e3\u8bfb\u6e90\u4ee3\u7801\u6216\u6280\u672f\u624b\u518c\u3002<\/p>\n\n\n\n<p>\u56de\u5230\u4e0a\u9762\u7684\u6280\u672f\u6808\u5206\u6790\u56fe\uff0c\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684Java Web\u5e94\u7528CRM\u7cfb\u7edf\uff0c\u5982\u679c\u57fa\u4e8eGWA2 Java \u8fdb\u884c\u6784\u5efa\uff0c\u76f4\u63a5\u5c31\u662fTomcat\u8dd1\u8d77\u6765\u4e00\u4e2a\u5e94\u7528\u5373\u53ef\u3002\u800c\u5982\u679c\u770b\u4e0a\u9762\u7684\u4f9b\u5e94\u94fe\uff0c\u5c31\u663e\u5f97\u590d\u6742\u65e0\u6bd4\uff0c\u5404\u79cd\u5c01\u88c5\u548c\u5d4c\u5957\u591a\u8fbe4-5\u5c42\uff0c\u800c\u6bcf\u4e00\u5c42\u5d4c\u5957\u53c8\u5f15\u5165\u66f4\u591a\u7684\u7b2c\u4e09\u65b9\u7ec4\u4ef6\uff0c\u7531\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u53d8\u5f97\u590d\u6742\u65e0\u6bd4\u3002\u5728\u5176\u6210\u672c\u4e0a\u5347\u7684\u540c\u65f6\uff0c\u5176\u5f00\u53d1\u95e8\u69db\u4e5f\u663e\u5f97\u9ad8\u9ad8\u5728\u4e0a\u4e86\uff0c\u51e0\u4e4e\u6ca1\u6709\u4e00\u4e2a\u4eba\u80fd\u591f\u5168\u90e8\u638c\u63e1\u6240\u6d89\u53ca\u7684\u5168\u90e8\u7ec4\u4ef6\u3002\u5bf9\u6bcf\u4e00\u4e2a\u7ec4\u4ef6\u4e0d\u8bf4\u53bb\u62c6\u89e3\u5206\u6790\u6e90\u4ee3\u7801\uff0c\u6050\u6015\u64cd\u4f5c\u4f7f\u7528\u8bf4\u660e\u6587\u6863\u80fd\u770b\u5b8c\u6574\u4e86\u4e5f\u975e\u6613\u4e8b\u3002<\/p>\n\n\n\n<p>\u4f9b\u5e94\u94fe\u8d8a\u957f\uff0c\u8d28\u91cf\u8d8a\u96be\u63a7\u5236\u3002<br \/>\u5728\u7acb\u5373\u53ef\u7528\u5c0f\u6b65\u5feb\u8dd1\u5feb\u901f\u8fed\u4ee3\u98ce\u884c\u7684\u65f6\u671f\uff0c\u53ef\u80fd\u5173\u4e4e\u8d28\u91cf\u3001\u6027\u80fd\u3001\u5b89\u5168\u7b49\u7686\u5c45\u4e8e\u6b21\u8981\u5730\u4f4d\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2020\/08\/gwa2-logo-202005.v3.png\" alt=\"\" \/><figcaption>GWA2<\/figcaption><\/figure>\n\n\n\n<p><a href=\"https:\/\/ufqi.com\/dev\/gwa2\/\">-GWA2 \u5409\u5a03\u5154<\/a>&nbsp;\u662f\u201d\u901a\u7528\u7f51\u7edc\u5e94\u7528\u67b6\u6784( General Web Application Architeture,&nbsp;https:\/\/ufqi.com\/dev\/gwa2\/ )\u201d\uff0c\u57fa\u4e8e -GWA2 \u53ef\u4ee5\u8f7b\u4fbf\u6784\u5efa\u5404\u79cd\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f,<br \/>\u5305\u62ec\u590d\u6742\u7684\u5728\u7ebf\u8d2d\u7269\u5546\u57ce\u3001\u5728\u7ebf\u533b\u7597\u3001\u5728\u7ebf\u6559\u80b2\u3001 \u65c5\u6e38\u4ea4\u6613\u5e73\u53f0\u3001\u793e\u7fa4\u6216\u8005\u793e\u4ea4\u7f51\u7ad9\u548c\u65b0\u95fb\u8d44\u8baf\u7f51\u7ad9\u7b49\uff0c<br \/>\u4e5f\u5305\u62ec\u5404\u79cd\u4f01\u4e8b\u4e1a\u5355\u4f4d\u7f51\u4e0a\u95e8\u6237\uff0c\u5728\u7ebf\u4ea4\u4e92\u53ca\u670d\u52a1\u4f5c\u4e1a\u7cfb\u7edf\u7b49.<br \/>\u8fd8\u53ef\u4ee5\u5305\u62ec\u4e3aNativeApp\u505a\u670d\u52a1\u5668\u7aef\u652f\u6301, \u751a\u81f3\u662fWebApp\u7684\u5168\u90e8.<br \/>-GWA2 \u662f\u4e3a\u6570\u4e0d\u591a\u7684\u652f\u6301\u8de8\u5f00\u53d1\u8bed\u8a00\u7684\u5e94\u7528\u6846\u67b6\uff0c\u76ee\u524d\u652f\u6301 -Java, -PHP, -Perl, -Aspx and -Python .<\/p>\n\n\n\n<p>-GWA2 is a \u201cGeneral Web Application Architecture\u201d and based on -GWA2 developers can easily build a variety of network applications,<br \/>including complex online shopping malls, online medical services, online teaching, travel trading platforms, community or social networking sites and news information sites, etc.<br \/>Also the applications include various online portals of enterprises and institutions, online interaction and service operations systems.<br \/>Moreover it contains server-side support for Native App, or even all of the WebApp.<br \/>-GWA2 is one of the web frameworks which provide cross-language support for -Java, -PHP, -Perl, -Aspx and -Python at present.<\/p>\n\n\n\n<p><strong>-GWA2 is E.A.S.Y&nbsp;<\/strong><br \/><strong>Easy Along, Swift Yield<br \/><\/strong>\u8f7b\u677e\u542f\u52a8, \u5feb\u901f\u4ea7\u51fa.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Annotations\u6ce8\u89e3\u548cJava Comments\u6ce8\u91ca\uff0c\u82f1\u6587\u91cc\u5dee\u522b &hellip; <a href=\"https:\/\/ufqi.com\/blog\/gwa2-java-annotations\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":2697,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[42,6,2],"tags":[454,146,456,455],"_links":{"self":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/2696"}],"collection":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/comments?post=2696"}],"version-history":[{"count":7,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/2696\/revisions"}],"predecessor-version":[{"id":3456,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/2696\/revisions\/3456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media\/2697"}],"wp:attachment":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media?parent=2696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/categories?post=2696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/tags?post=2696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}