{"id":48223,"date":"2024-12-02T15:38:12","date_gmt":"2024-12-02T07:38:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48223\/"},"modified":"2024-12-02T15:38:12","modified_gmt":"2024-12-02T07:38:12","slug":"%e5%8f%8d%e5%b0%84-nosuchmethodexception%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e8%b0%83%e7%94%a8-getname-%e6%96%b9%e6%b3%95%e6%97%b6%e4%bc%9a%e6%8a%9b%e5%87%ba%e5%bc%82%e5%b8%b8%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48223\/","title":{"rendered":"\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f<\/h1>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241106\/1730879326672b1f5e2ee5c.jpg\" class=\"aligncenter\" title=\"\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f\u63d2\u56fe\" alt=\"\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u53cd\u5c04 nosuchmethodexception<\/strong><\/p>\n<p>\u5728 java \u4e2d\u4f7f\u7528\u53cd\u5c04\u65f6\uff0c\u6709\u65f6\u4f1a\u9047\u5230 nosuchmethodexception \u5f02\u5e38\u3002\u6b64\u5f02\u5e38\u8868\u793a\u6b63\u5728\u5bfb\u627e\u7684\u65b9\u6cd5\u4e0d\u5b58\u5728\u4e8e\u7ed9\u5b9a\u7684\u7c7b\u6216\u63a5\u53e3\u4e2d\u3002<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u95ee\u9898\u51fa\u5728\u4f60\u8bd5\u56fe\u83b7\u53d6 getname \u65b9\u6cd5\u65f6\u4f20\u9012\u4e86\u4e00\u4e2a\u53c2\u6570\uff08&#8221;string.class&#8221;\uff09\uff0c\u4f46\u5b9e\u9645\u4e0a\u8fd9\u4e2a\u65b9\u6cd5\u6ca1\u6709\u53c2\u6570\u3002\u6b63\u786e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>Method method = c.getMethod(\"getName\");<\/pre>\n<p>\u4ee5\u4e0b\u662f\u95ee\u9898\u7684\u8be6\u7ec6\u89e3\u7b54\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 class.forname \u52a0\u8f7d &#8220;com.demo.pojo.user&#8221; \u7c7b\u3002<\/li>\n<li>\u521b\u5efa\u8be5\u7c7b\u7684\u5b9e\u4f8b\u3002<\/li>\n<li>\u83b7\u53d6\u7c7b\u7684\u6240\u6709\u65b9\u6cd5\u3002<\/li>\n<li>\u5c1d\u8bd5\u83b7\u53d6 getname \u65b9\u6cd5\uff0c\u9519\u8bef\u5730\u4f20\u9012\u4e86\u4e00\u4e2a\u53c2\u6570\u3002\u8fd9\u4f1a\u5f15\u53d1 nosuchmethodexception \u5f02\u5e38\u3002<\/li>\n<\/ol>\n<p>\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5c06\u8fd4\u56de &#8220;user&#8221; \u5b57\u7b26\u4e32\uff0c\u56e0\u4e3a getname \u65b9\u6cd5\u6ca1\u6709\u53c2\u6570\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f \u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01 \u53cd\u5c04 nosuchmethodexception \u5728 java \u4e2d\u4f7f\u7528\u53cd\u5c04\u65f6\uff0c\u6709\u65f6\u4f1a\u9047\u5230 nosuchmethodexception \u5f02\u5e38\u3002\u6b64\u5f02\u5e38\u8868\u793a\u6b63\u5728\u5bfb\u627e\u7684\u65b9\u6cd5\u4e0d\u5b58\u5728\u4e8e\u7ed9\u5b9a\u7684\u7c7b\u6216\u63a5\u53e3\u4e2d\u3002 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u95ee\u9898\u51fa\u5728\u4f60\u8bd5\u56fe\u83b7\u53d6 getname \u65b9\u6cd5\u65f6\u4f20\u9012\u4e86\u4e00\u4e2a\u53c2\u6570\uff08&#8221;string.class&#8221;\uff09\uff0c\u4f46\u5b9e\u9645\u4e0a\u8fd9\u4e2a\u65b9\u6cd5\u6ca1\u6709\u53c2\u6570\u3002\u6b63\u786e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a Method method = c.getMethod(&#8220;getName&#8221;); \u4ee5\u4e0b\u662f\u95ee\u9898\u7684\u8be6\u7ec6\u89e3\u7b54\uff1a \u4f7f\u7528 class.forname \u52a0\u8f7d &#8220;com.demo.pojo.user&#8221; \u7c7b\u3002 \u521b\u5efa\u8be5\u7c7b\u7684\u5b9e\u4f8b\u3002 \u83b7\u53d6\u7c7b\u7684\u6240\u6709\u65b9\u6cd5\u3002 \u5c1d\u8bd5\u83b7\u53d6 getname \u65b9\u6cd5\uff0c\u9519\u8bef\u5730\u4f20\u9012\u4e86\u4e00\u4e2a\u53c2\u6570\u3002\u8fd9\u4f1a\u5f15\u53d1 nosuchmethodexception \u5f02\u5e38\u3002 \u4fee\u6539\u540e\u7684\u4ee3\u7801\u5c06\u8fd4\u56de &#8220;user&#8221; \u5b57\u7b26\u4e32\uff0c\u56e0\u4e3a getname \u65b9\u6cd5\u6ca1\u6709\u53c2\u6570\u3002 \u4ee5\u4e0a\u5c31\u662f\u300a\u53cd\u5c04 NoSuchMethodException\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528 getName \u65b9\u6cd5\u65f6\u4f1a\u629b\u51fa\u5f02\u5e38\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48223","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48223"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48223\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}