{"id":125769,"date":"2020-06-26T20:51:32","date_gmt":"2020-06-26T12:51:32","guid":{"rendered":"http:\/\/4563.org\/?p=125769"},"modified":"2020-06-26T20:51:32","modified_gmt":"2020-06-26T12:51:32","slug":"spring-boot-%e7%9a%84-conditionalonclass-%e6%80%8e%e4%b9%88%e5%81%9a%e5%88%b0%e4%bb%a5-class-%e4%b8%ba%e5%8f%82%e6%95%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=125769","title":{"rendered":"spring boot \u7684 @ConditionalOnClass \u600e\u4e48\u505a\u5230\u4ee5 Class \u4e3a\u53c2\u6570\u7684\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  spring boot \u7684 @ConditionalOnClass \u600e\u4e48\u505a\u5230\u4ee5 Class \u4e3a\u53c2\u6570\u7684\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u7528\u7c7b Abc \u8868\u793a\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u7c7b\uff0c\u5f53\u4ee3\u7801\u4e2d\u51fa\u73b0 Abc.class \u65f6\u80af\u5b9a\u4f1a\u62a5\u9519\uff0c\u9996\u5148 IDE \u5e76\u6ca1\u6709\u627e\u5230\u8fd9\u6837\u4e00\u4e2a\u7c7b\u4ece\u800c\u65e0\u6cd5\u5728\u6587\u4ef6\u9876\u90e8\u5199\u597d import &#8230;.Abc \uff0c\u8fdb\u800c\u7f16\u8bd1\u5668\u4e0d\u77e5\u9053\u4f60\u5199\u4e86\u4e2a\u4ec0\u4e48\u4e1c\u897f\uff0c\u6700\u7ec8\u62a5\u9519\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\u5982\u679c\u7c7b Abc \u4e0d\u5b58\u5728\uff08\u81ea\u5df1\u7684\u9879\u76ee\u91cc\u6ca1\u6709\u521b\u5efa\u8fd9\u6837\u4e00\u4e2a\u7c7b\uff0c\u9879\u76ee\u7684\u4f9d\u8d56\u4e2d\u4e5f\u6ca1\u6709\u8fd9\u6837\u4e00\u4e2a\u7c7b\uff0c\u6700\u7ec8\u5bfc\u81f4\u6587\u4ef6\u9876\u90e8\u6ca1\u6709 import \u8fd9\u6837\u4e00\u4e2a\u7c7b\uff09\uff0c@ConditionalOnClass(Abc.class) \u6839\u672c\u5c31\u901a\u4e0d\u8fc7\u7f16\u8bd1\u4e0d\u5bf9\u4e48\uff1f<\/p>\n<p>\u7136\u540e spring boot \u81ea\u52a8\u914d\u7f6e\u4e2d @ConditionalOnClass \u4f7f\u7528\u65f6\u7684\u610f\u601d\u662f\uff1a\u5f53\u4f5c\u4e3a\u8fd9\u4e2a\u6ce8\u89e3\u7684\u53c2\u6570\u7684\u7c7b\u5b58\u5728\u65f6\uff0c\u624d\u542f\u7528\u914d\u7f6e\u7c7b\u3002\u53ef\u662f\u5982\u679c\u8fd9\u4e2a\u7c7b\u4e0d\u5b58\u5728\uff0c\u4e0d\u5e94\u8be5\u51fa\u73b0\u6211\u4e0a\u9762\u8bf4\u7684\u95ee\u9898\uff1a\u7f16\u8bd1\u901a\u4e0d\u8fc7\uff0c\u9879\u76ee\u5b8c\u5168\u8dd1\u4e0d\u8d77\u6765\u3002\u3002\u3002<\/p>\n<p>\u8c22\u8c22      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2162703\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : raptium <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7f16\u8bd1\u65f6\u7684 classpath \u548c\u8fd0\u884c\u65f6\u7684 classpath \u53ef\u4ee5\u4e0d\u4e00\u6837\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162704\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @raptium maven \u7684 dependency \u4e2d scope=import \uff1f\u4e8e\u662f\u5728\u7f16\u8bd1\u65f6\u6709\u5728\u8fd0\u884c\u65f6\u6ca1\u6709\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2162705\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zankard <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             spring boot \u7528 asm \u6765\u89e3\u6790 @ConditionalOnClass \u7684 metadata\uff0c\u6587\u6863\u4e0a\u5c31\u5df2\u7ecf\u8bf4\u660e\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>spring boot \u7684 @Co&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/125769"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125769"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/125769\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125769"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}