{"id":2950,"date":"2018-08-03T14:41:40","date_gmt":"2018-08-03T06:41:40","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2950"},"modified":"2018-08-03T14:42:54","modified_gmt":"2018-08-03T06:42:54","slug":"bean-method-feigncontext-not-loaded-because-conditionalonclass-did-not-find-required-class-feign-feign","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2950","title":{"rendered":"Bean method &#8216;feignContext&#8217; not loaded because @ConditionalOnClass did not find required class &#8216;feign.Feign&#8217;"},"content":{"rendered":"<p>\n\t\u4eca\u5929\u7528 Spring cloud \u5199\u4e86\u4e00\u4e2a\u7535\u5546\u9879\u76ee\u7684 demo\uff0c\u5728\u670d\u52a1\u6d88\u8d39\u65b9\u542f\u52a8\u65f6\uff0c\u9047\u5230\u4e86\u4e00\u4e2a\u5f02\u5e38\uff1aBean method &#039;feignContext&#039; not loaded because @ConditionalOnClass did not find required class &#039;feign.Feign&#039;\u3002\u672c\u6587\u603b\u7ed3\u8fd9\u4e2a\u5f02\u5e38\u7684\u89e3\u51b3\u529e\u6cd5\u3002\n<\/p>\n<p>\n\t\u5b8c\u6574\u5f02\u5e38\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\t***************************<br \/>\n\tAPPLICATION FAILED TO START<br \/>\n\t***************************\n<\/p>\n<p>\n\t<br \/>\n\tDescription:\n<\/p>\n<p>\n\t<br \/>\n\tA component required a bean of type &#039;org.springframework.cloud.netflix.feign.FeignContext&#039; that could not be found.<br \/>\n\t&nbsp; &nbsp; &nbsp;&#8211; Bean method &#039;feignContext&#039; not loaded because @ConditionalOnClass did not find required class &#039;feign.Feign&#039;\n<\/p>\n<p>\n\t\u6839\u636e\u8fd9\u4e2a\u5f02\u5e38\u63d0\u793a\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u77e5\uff0c\u5728\u6267\u884c&nbsp;feignContext \u65b9\u6cd5\u65f6\uff0c\u7528\u5230\u4e86\u6761\u4ef6\u5224\u65ad\u6ce8\u89e3&nbsp;@ConditionalOnClass\u3002@ConditionalOnClass \u6ce8\u89e3\u4f1a\u5224\u65ad\u67d0\u4e2a class \u5df2\u7ecf\u6210\u529f\u52a0\u8f7d\uff0c\u624d\u4f1a\u5b9e\u4f8b\u5316\u8fd9\u4e2a Bean\u3002\u73b0\u5728\u629b\u51fa&nbsp;did not find required class \uff0c\u8bf4\u660e\u6211\u4eec\u7f3a\u5c11\u5bf9\u5e94\u7684 jar \u6587\u4ef6\u3002\n<\/p>\n<p>\n\t\u56e0\u4e3a\u6211\u4eec\u670d\u52a1\u6d88\u8d39\u65b9\u4f7f\u7528\u4e86&nbsp;@FeignClient \u6ce8\u89e3\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@FeignClient(name = &quot;order-cloud&quot;)\r\npublic interface OrderService {\r\n\r\n    @RequestMapping(&quot;\/order\/detail&quot;)\r\n    String getOrder();\r\n\r\n}<\/pre>\n<p>\n\t\u4f46\u662f\u5b9e\u9645\u7684 pom.xml \u6587\u4ef6\u4e2d\uff0c\u5e76\u6ca1\u6709\u5f15\u5165\u5bf9\u5e94\u7684&nbsp;starter\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5728 pom.xml \u4e2d\u505a\u5982\u4e0b\u914d\u7f6e\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-eureka&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n\r\n&lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-feign&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>\n\t\u6ce8\u610f\uff0c\u53ea\u914d\u7f6e&nbsp;spring-cloud-starter-eureka \u5c31\u4f1a\u62a5\u8fd9\u4e2a\u5f02\u5e38\u3002\u53e6\u5916\uff0c\u542f\u52a8\u7c7b\u4e0a\u9700\u8981\u52a0\u4e0a&nbsp;@EnableFeignClients \u6ce8\u89e3\uff0c\u8981\u4e0d\u7136&nbsp;@FeignClient \u6ce8\u89e3\u4e0d\u4f1a\u8d77\u4f5c\u7528\u7684\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2950\">Bean method &#8216;feignContext&#8217; not loaded because @ConditionalOnClass did not find required class &#8216;feign.Feign&#8217;<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u7528 Spring cloud \u5199\u4e86\u4e00\u4e2a\u7535\u5546\u9879\u76ee\u7684 demo\uff0c\u5728\u670d\u52a1\u6d88\u8d39\u65b9\u542f\u52a8\u65f6\uff0c\u9047\u5230\u4e86\u4e00\u4e2a\u5f02\u5e38\uff1aBean  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[1659,587,588,581,510],"class_list":["post-2950","post","type-post","status-publish","format-standard","hentry","category-java","category-yyzt","tag-feign","tag-spring-boot","tag-spring-cloud","tag-581","tag-510"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2950"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2950\/revisions"}],"predecessor-version":[{"id":2952,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2950\/revisions\/2952"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}