{"id":1000,"date":"2022-08-16T14:15:03","date_gmt":"2022-08-16T06:15:03","guid":{"rendered":"https:\/\/usei.cn\/?p=1000"},"modified":"2022-08-19T14:31:44","modified_gmt":"2022-08-19T06:31:44","slug":"springboot-%e8%87%aa%e5%ae%9a%e4%b9%89%e6%b3%a8%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/usei.cn\/index.php\/2022\/08\/16\/springboot-%e8%87%aa%e5%ae%9a%e4%b9%89%e6%b3%a8%e8%a7%a3\/","title":{"rendered":"Springboot \u81ea\u5b9a\u4e49\u6ce8\u89e3"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u65b0\u589e\u6ce8\u89e3<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.join.payment.core;\n\nimport java.lang.annotation.*;\n\n\/**\n * \u53ef\u652f\u4ed8\u8ba2\u5355\u6ce8\u89e3\n * @author Administrator\n *\/\n@Target(ElementType.TYPE) \/\/ \u4f5c\u7528\u4e8e\u7c7b\u4e0a\n@Retention(RetentionPolicy.RUNTIME) \/\/ \u8fd0\u884c\u65f6\u53ef\u89c1\n@Inherited \/\/ \u53ef\u7ee7\u627f\n@Documented \/\/ javadoc \u53ef\u89c1\npublic @interface PaymentOrder {\n\n    String value();\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5728\u9700\u8981\u7684\u7c7b\u4e0a\u6ce8\u89e3<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@PaymentOrder(\"order\")\npublic class MyOrder{\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>      @Target(ElementType.TYPE)  \u2014\u2014\u300b\u63a5\u53e3\u3001\u7c7b\n      @Target(ElementType.FIELD)   \u2014\u2014\u300b\u5c5e\u6027\n      @Target(ElementType.METHOD)   \u2014\u2014\u300b\u65b9\u6cd5\n      @Target(ElementType.PARAMETER)   \u2014\u2014\u300b\u65b9\u6cd5\u53c2\u6570\n      @Target(ElementType.CONSTRUCTOR)  \u2014\u2014\u300b\u6784\u9020\u51fd\u6570\n      @Target(ElementType.LOCAL_VARIABLE)  \u2014\u2014\u300b\u5c40\u90e8\u53d8\u91cf\n      @Target(ElementType.ANNOTATION_TYPE)  \u2014\u2014\u300b\u6ce8\u89e3\n      @Target(ElementType.PACKAGE)   \u2014\u2014\u300b\u5305 <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u626b\u63cf\u6ce8\u89e3\u7c7b \u5e76\u83b7\u5f97\u6ce8\u89e3\u53c2\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code> String basePackage = \"com.ruoyi\";\r\n        Reflections f = new Reflections(basePackage);\r\n        Set&lt;Class&lt;?>> set = f.getTypesAnnotatedWith(PaymentOrder.class);\r\n        for (Class&lt;?> c : set) {\r\n            PaymentOrder annotation = c.getAnnotation(PaymentOrder.class);\r\n            if (annotation !=null){\r\n                String businessName = annotation.value();\r\n                if(StringUtils.hasLength(businessName)){\r\n                    this.map.put(businessName,c);\r\n                }\r\n            }\r\n        }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u589e\u6ce8\u89e3 \u5728\u9700\u8981\u7684\u7c7b\u4e0a\u6ce8\u89e3 \u626b\u63cf\u6ce8\u89e3\u7c7b \u5e76\u83b7\u5f97\u6ce8\u89e3\u53c2\u6570<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,75],"tags":[],"class_list":["post-1000","post","type-post","status-publish","format-standard","hentry","category-java","category-springboot"],"_links":{"self":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/1000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1000"}],"version-history":[{"count":6,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/1000\/revisions"}],"predecessor-version":[{"id":1049,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/1000\/revisions\/1049"}],"wp:attachment":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}