{"id":35045,"date":"2024-11-26T15:41:04","date_gmt":"2024-11-26T07:41:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/35045\/"},"modified":"2024-11-26T15:41:04","modified_gmt":"2024-11-26T07:41:04","slug":"springboot-%e4%b8%ad%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%ad%e5%af%b9%e8%b1%a1%e4%b8%ba%e7%a9%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/35045\/","title":{"rendered":"SpringBoot \u4e2d\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173059543467801.jpg\" class=\"aligncenter\" title=\"SpringBoot \u4e2d\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a\uff1f\u63d2\u56fe\" alt=\"SpringBoot \u4e2d\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>SpringBoot \u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 JPA \u67e5\u8be2\u6570\u636e\u65f6\uff0c\u6709\u65f6\u4f1a\u51fa\u73b0 IntelliJ IDEA \u63d0\u793a &#8220;Cannot resolve symbol&#8221; \u4ee5\u53ca &#8220;Result of method is incompatible with expected type&#8221; \u7684\u9519\u8bef\u3002\u8fd9\u901a\u5e38\u662f\u56e0\u4e3a\u7cfb\u7edf\u5c06\u5bf9\u8c61\u89c6\u4e3a\u975e\u7a7a\uff0c\u4f46\u53c8\u6dfb\u52a0\u4e86\u7a7a\u5224\u65ad\u5bfc\u81f4\u7684\u3002<\/p>\n<p><strong>\u95ee\u9898\u89e3\u6790<\/strong><\/p>\n<p>\u6839\u636e\u63d0\u793a\u7684\u4fe1\u606f\uff0c\u95ee\u9898\u7684\u6838\u5fc3\u5728\u4e8e\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u7a7a\u3002\u9519\u8bef\u63d0\u793a\u8868\u660e\uff0c\u5bf9\u8c61\u5728 System.out.print \u4e2d\u88ab\u8c03\u7528\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u5219\u4f1a\u51fa\u73b0\u9519\u8bef\u3002\u7136\u800c\uff0c\u7531\u4e8e\u7cfb\u7edf\u5047\u5b9a\u8be5\u5bf9\u8c61\u975e\u7a7a\uff0c\u800c\u7a0b\u5e8f\u4e2d\u53c8\u5305\u542b\u7a7a\u5224\u65ad\uff0c\u56e0\u6b64\u4ea7\u751f\u4e86\u77db\u76fe\uff0c\u5bfc\u81f4\u9519\u8bef\u63d0\u793a\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8be5\u95ee\u9898\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u60c5\u51b5\u7075\u6d3b\u5904\u7406\uff1a<\/p>\n<ul>\n<li> <strong>\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a null\uff1a<\/strong>\u53ef\u4ee5\u4f7f\u7528\u4f20\u7edf\u7684 null \u68c0\u67e5\uff0c\u5373 if (object == null)\u3002<\/li>\n<li> <strong>\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u7a7a\u96c6\u5408\u6216\u7a7a\u5b57\u7b26\u4e32\uff1a<\/strong>\u5bf9\u4e8e\u96c6\u5408\u6216\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 isEmpty() \u6216 isBlank() \u7b49\u65b9\u6cd5\u8fdb\u884c\u5224\u65ad\u3002<\/li>\n<li> <strong>\u6839\u636e\u4e1a\u52a1\u903b\u8f91\u5224\u65ad\uff1a<\/strong>\u5982\u679c\u5bf9\u8c61\u4e3a\u7a7a\u7684\u95ee\u9898\u662f\u7531\u4e8e\u4e1a\u52a1\u903b\u8f91\u5bfc\u81f4\u7684\uff0c\u5219\u9700\u8981\u4fee\u6539\u4e1a\u52a1\u903b\u8f91\uff0c\u4ee5\u6b63\u786e\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u7a7a\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fSpringBoot \u4e2d\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SpringBoot \u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a \u5728\u4f7f\u7528 JPA \u67e5\u8be2\u6570\u636e\u65f6\uff0c\u6709\u65f6\u4f1a\u51fa\u73b0 IntelliJ IDEA \u63d0\u793a &#8220;Cannot resolve symbol&#8221; \u4ee5\u53ca &#8220;Result of method is incompatible with expected type&#8221; \u7684\u9519\u8bef\u3002\u8fd9\u901a\u5e38\u662f\u56e0\u4e3a\u7cfb\u7edf\u5c06\u5bf9\u8c61\u89c6\u4e3a\u975e\u7a7a\uff0c\u4f46\u53c8\u6dfb\u52a0\u4e86\u7a7a\u5224\u65ad\u5bfc\u81f4\u7684\u3002 \u95ee\u9898\u89e3\u6790 \u6839\u636e\u63d0\u793a\u7684\u4fe1\u606f\uff0c\u95ee\u9898\u7684\u6838\u5fc3\u5728\u4e8e\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u7a7a\u3002\u9519\u8bef\u63d0\u793a\u8868\u660e\uff0c\u5bf9\u8c61\u5728 System.out.print \u4e2d\u88ab\u8c03\u7528\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u5219\u4f1a\u51fa\u73b0\u9519\u8bef\u3002\u7136\u800c\uff0c\u7531\u4e8e\u7cfb\u7edf\u5047\u5b9a\u8be5\u5bf9\u8c61\u975e\u7a7a\uff0c\u800c\u7a0b\u5e8f\u4e2d\u53c8\u5305\u542b\u7a7a\u5224\u65ad\uff0c\u56e0\u6b64\u4ea7\u751f\u4e86\u77db\u76fe\uff0c\u5bfc\u81f4\u9519\u8bef\u63d0\u793a\u3002 \u89e3\u51b3\u65b9\u6848 \u4e3a\u4e86\u89e3\u51b3\u8be5\u95ee\u9898\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u60c5\u51b5\u7075\u6d3b\u5904\u7406\uff1a \u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a null\uff1a\u53ef\u4ee5\u4f7f\u7528\u4f20\u7edf\u7684 null \u68c0\u67e5\uff0c\u5373 if (object == null)\u3002 \u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u7a7a\u96c6\u5408\u6216\u7a7a\u5b57\u7b26\u4e32\uff1a\u5bf9\u4e8e\u96c6\u5408\u6216\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 isEmpty() \u6216 isBlank() \u7b49\u65b9\u6cd5\u8fdb\u884c\u5224\u65ad\u3002 \u6839\u636e\u4e1a\u52a1\u903b\u8f91\u5224\u65ad\uff1a\u5982\u679c\u5bf9\u8c61\u4e3a\u7a7a\u7684\u95ee\u9898\u662f\u7531\u4e8e\u4e1a\u52a1\u903b\u8f91\u5bfc\u81f4\u7684\uff0c\u5219\u9700\u8981\u4fee\u6539\u4e1a\u52a1\u903b\u8f91\uff0c\u4ee5\u6b63\u786e\u5224\u65ad\u5bf9\u8c61\u662f\u5426\u4e3a\u7a7a\u3002 \u4ee5\u4e0a\u5c31\u662fSpringBoot \u4e2d\u5982\u4f55\u5224\u65ad\u5bf9\u8c61\u4e3a\u7a7a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\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-35045","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35045","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=35045"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/35045\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=35045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=35045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=35045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}