{"id":9620,"date":"2023-11-28T21:07:45","date_gmt":"2023-11-28T13:07:45","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=9620"},"modified":"2023-12-06T17:23:51","modified_gmt":"2023-12-06T09:23:51","slug":"springcloud-zhongspringbootapplication-zhu-jie-zai","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/springcloud-zhongspringbootapplication-zhu-jie-zai\/","title":{"rendered":"SpringCloud \u4e2d\u00a9SpringBootApplication \u6ce8\u89e3\u5728\u5185\u90e8\u6709\u4ec0\u4e48\u7528\u5904\uff1f"},"content":{"rendered":"<p>\u5728 Spring Cloud \u4e2d\uff0c<code>@SpringBootApplication<\/code> \u6ce8\u89e3\u662f\u4e00\u4e2a\u7ec4\u5408\u6ce8\u89e3\uff0c\u5b83\u6574\u5408\u4e86\u591a\u4e2a\u6ce8\u89e3\uff0c\u4e3b\u8981\u7528\u4e8e\u6807\u8bc6\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7c7b\u3002\u8fd9\u4e2a\u6ce8\u89e3\u5305\u542b\u4ee5\u4e0b\u4e09\u4e2a\u91cd\u8981\u7684\u6ce8\u89e3\uff1a<\/p>\n<ol>\n<li>\n<strong><code>@SpringBootConfiguration<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u8868\u793a\u8be5\u7c7b\u662f\u4e00\u4e2a\u914d\u7f6e\u7c7b\uff0c\u7c7b\u4f3c\u4e8e\u4f7f\u7528 <code>@Configuration<\/code> \u6ce8\u89e3\u6807\u8bc6\u7684\u914d\u7f6e\u7c7b\u3002<code>@SpringBootConfiguration<\/code> \u5b9e\u9645\u4e0a\u662f <code>@Configuration<\/code> \u7684\u7279\u6b8a\u5f62\u5f0f\uff0c\u7528\u4e8e\u6307\u793a\u8fd9\u662f\u4e00\u4e2a Spring Boot \u7684\u914d\u7f6e\u7c7b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong><code>@EnableAutoConfiguration<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u5f00\u542f\u81ea\u52a8\u914d\u7f6e\uff0c\u8ba9 Spring Boot \u6839\u636e\u9879\u76ee\u7684\u4f9d\u8d56\u914d\u7f6e\u6765\u81ea\u52a8\u914d\u7f6e\u9879\u76ee\u7684\u914d\u7f6e\u3002Spring Boot \u7684\u81ea\u52a8\u914d\u7f6e\u662f\u4e00\u79cd\u7ea6\u5b9a\u4f18\u4e8e\u914d\u7f6e\u7684\u673a\u5236\uff0c\u6839\u636e\u9879\u76ee\u7684\u4f9d\u8d56\u548c\u7c7b\u8def\u5f84\u4e0a\u7684 JAR \u5305\uff0c\u81ea\u52a8\u914d\u7f6e\u9879\u76ee\u7684\u73af\u5883\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong><code>@ComponentScan<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u542f\u7528\u7ec4\u4ef6\u626b\u63cf\uff0c\u81ea\u52a8\u626b\u63cf\u5e76\u6ce8\u518c\u88ab <code>@Component<\/code> \u53ca\u5176\u6d3e\u751f\u6ce8\u89e3\u6807\u6ce8\u7684\u7c7b\uff0c\u4f7f\u8fd9\u4e9b\u7c7b\u6210\u4e3a Spring \u5bb9\u5668\u7ba1\u7406\u7684\u7ec4\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u7efc\u5408\u8d77\u6765\uff0c<code>@SpringBootApplication<\/code> \u6ce8\u89e3\u7684\u4e3b\u8981\u76ee\u7684\u662f\u5c06\u4e00\u4e2a\u7c7b\u6807\u8bc6\u4e3a Spring Boot \u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u7c7b\uff0c\u5e76\u542f\u7528\u81ea\u52a8\u914d\u7f6e\u548c\u7ec4\u4ef6\u626b\u63cf\u3002\u5b83\u7b80\u5316\u4e86 Spring Boot \u9879\u76ee\u7684\u914d\u7f6e\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u65e0\u9700\u624b\u52a8\u914d\u7f6e\u592a\u591a\u7684\u5185\u5bb9\uff0c\u901a\u8fc7\u7ea6\u5b9a\u4f18\u4e8e\u914d\u7f6e\u7684\u65b9\u5f0f\uff0c\u5feb\u901f\u642d\u5efa\u548c\u8fd0\u884c Spring Boot \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre><code class=\"language-java\">@SpringBootApplication\npublic class MyApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(MyApplication.class, args);\n    }\n}\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>@SpringBootApplication<\/code> \u6ce8\u89e3\u6807\u8bc6\u4e86\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7c7b <code>MyApplication<\/code>\uff0c\u5e76\u901a\u8fc7 <code>SpringApplication.run<\/code> \u542f\u52a8\u4e86 Spring Boot \u5e94\u7528\u7a0b\u5e8f\u3002\u8be5\u6ce8\u89e3\u7684\u5185\u90e8\u5305\u542b\u7684\u4e09\u4e2a\u6ce8\u89e3\u5e2e\u52a9\u914d\u7f6e\u4e86 Spring Boot \u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u57fa\u672c\u5143\u7d20\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Spring Cloud \u4e2d\uff0c@SpringBootApplication \u6ce8\u89e3\u662f\u4e00\u4e2a\u7ec4\u5408\u6ce8\u89e3\uff0c\u5b83\u6574\u5408\u4e86\u591a [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[],"class_list":["post-9620","post","type-post","status-publish","format-standard","hentry","category-springcloud"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=9620"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9620\/revisions"}],"predecessor-version":[{"id":16745,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9620\/revisions\/16745"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=9620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=9620"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=9620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}