{"id":5834,"date":"2024-04-16T00:26:21","date_gmt":"2024-04-15T16:26:21","guid":{"rendered":"http:\/\/zyg.luchers.cn\/?p=5834"},"modified":"2024-04-16T00:26:21","modified_gmt":"2024-04-15T16:26:21","slug":"%e4%b8%80%e3%80%81springboot3%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"http:\/\/zyg.luchers.cn\/index.php\/2024\/04\/16\/%e4%b8%80%e3%80%81springboot3%e4%bb%8b%e7%bb%8d\/","title":{"rendered":"\u4e00\u3001SPringBoot3\u4ecb\u7ecd"},"content":{"rendered":"<h1>\u4e00\u3001SPringBoot3\u4ecb\u7ecd<\/h1>\n<h2>1\u3001\u4ecb\u7ecd<\/h2>\n<h3>1\u3001\u4f7f\u7528\u7248\u672c<\/h3>\n<p>1\u3001\u8fd9\u8bfe\u7a0b\u4f7f\u7528SpringBoot\u7248\u672c\uff1a3.0.5<\/p>\n<h3>2\u3001\u4e3a\u4ec0\u4e48\u4f7f\u7528<\/h3>\n<p>1\u3001\u6211\u4eec\u4e4b\u524d\u5b66\u4e86ssm\u6574\u5408\u3002\u53d1\u73b0\u8981\u914d\u7f6e\u5f88\u591a\u7684\u6587\u4ef6\u3002\u8ba9\u4eba\u5f88\u4e0d\u8212\u670d<\/p>\n<p>2\u3001Spring\u5bb6\u65cf\uff0c\u5c31\u542f\u52a8<strong>SPringBoot\u6765\u5e2e\u52a9\u6211\u4eec\u7b80\u5316\u914d\u7f6e\uff01\uff01\uff01<\/strong><\/p>\n<h3>3\u3001\u76ee\u6807<\/h3>\n<p>1\u3001 \u4e3a\u6240\u6709 Spring \u5f00\u53d1\u63d0\u4f9b\u66f4\u5feb\u901f\u3001\u53ef\u5e7f\u6cdb\u8bbf\u95ee\u7684\u5165\u95e8\u4f53\u9a8c\u3002<\/p>\n<p>2\u3001\u5f00\u7bb1\u5373\u7528\uff0c\u8bbe\u7f6e\u5408\u7406\u7684\u9ed8\u8ba4\u503c\uff0c\u4f46\u662f\u4e5f\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u8fdb\u884c\u9002\u5f53\u7684\u8c03\u6574\u3002<\/p>\n<p>3\u3001\u63d0\u4f9b\u4e00\u7cfb\u5217\u5927\u578b\u9879\u76ee\u901a\u7528\u7684\u975e\u529f\u80fd\u6027\u7a0b\u5e8f\uff08\u5982\u5d4c\u5165\u5f0f\u670d\u52a1\u5668\u3001\u5b89\u5168\u6027\u3001\u6307\u6807\u3001\u8fd0\u884c\u68c0\u67e5\u7b49\uff09\u3002<\/p>\n<p>4\u3001<strong>\u7ea6\u5b9a\u5927\u4e8e\u914d\u7f6e<\/strong>\uff0c\u57fa\u672c\u4e0d\u9700\u8981\u4e3b\u52a8\u7f16\u5199\u914d\u7f6e\u7c7b\u3001\u4e5f\u4e0d\u9700\u8981 XML \u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<h3>4\u3001\u603b\u7ed3<\/h3>\n<p>1\u3001<strong>\u7b80\u5316\u5f00\u53d1\uff0c\u7b80\u5316\u914d\u7f6e\uff0c\u7b80\u5316\u6574\u5408\uff0c\u7b80\u5316\u90e8\u7f72\uff0c\u7b80\u5316\u76d1\u63a7\uff0c\u7b80\u5316\u8fd0\u7ef4\u3002<\/strong><\/p>\n<h2>2\u3001\u7cfb\u7edf\u8981\u6c42<\/h2>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u6280\u672f&amp;\u5de5\u5177<\/td>\n<td>\u7248\u672c\uff08or later\uff09<\/td>\n<\/tr>\n<tr>\n<td>maven<\/td>\n<td>3.6.3 or later 3.6.3 \u6216\u66f4\u9ad8\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td>Tomcat<\/td>\n<td>10.0+<\/td>\n<\/tr>\n<tr>\n<td>Servlet<\/td>\n<td>9.0+<\/td>\n<\/tr>\n<tr>\n<td>JDK<\/td>\n<td>17+<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>3\u3001\u5feb\u901f\u5165\u95e8<\/h2>\n<h3>1\u3001\u9700\u6c42<\/h3>\n<p>1\u3001\u6d4f\u89c8\u5668\u53d1\u9001\/hello\u8bf7\u6c42\uff0c\u8fd4\u56de&quot;Hello,Spring Boot 3!&quot;<\/p>\n<h3>2\u3001\u64cd\u4f5c\u6b65\u9aa4<\/h3>\n<p>1\u3001\u5148\u521b\u5efa\u9879\u76ee<\/p>\n<p>2\u3001\u7ed9\u9879\u76ee\u6dfb\u52a0\u4f9d\u8d56\uff08Springboot\u7236\u5de5\u7a0b\u4f9d\u8d56\uff0cweb\u542f\u52a8\u5668\u4f9d\u8d56\uff09<\/p>\n<ul>\n<li>\n<p>\u7ee7\u627f\u4e86Springboot\u7236\u5de5\u7a0b\u4f9d\u8d56\uff0c\u5c31\u53ef\u4ee5\u7b80\u5316\u5f88\u591a\u914d\u7f6e\u3002\u56e0\u4e3a\u7236\u5de5\u7a0b\u5df2\u7ecf\u914d\u7f6e\u4e86<\/p>\n<\/li>\n<li>\n<p>\u7236\u5de5\u7a0b\u4f9d\u8d56<\/p>\n<\/li>\n<li>\n<pre><code class=\"language-xml\"><parent> \n  <!--        springboot-->  \n  <groupId>org.springframework.boot<\/groupId>  \n  <artifactId>spring-boot-starter-parent<\/artifactId>  \n  <version>3.0.5<\/version> \n<\/parent>  <\/code><\/pre>\n<\/li>\n<li>\n<p>web\u542f\u52a8\u5668\u4f9d\u8d56<\/p>\n<\/li>\n<li>\n<pre><code class=\"language-xml\"><dependencies> \n  <!--web\u5f00\u53d1\u7684\u573a\u666f\u542f\u52a8\u5668-->  \n  <dependency> \n    <groupId>org.springframework.boot<\/groupId>  \n    <artifactId>spring-boot-starter-web<\/artifactId> \n  <\/dependency> \n<\/dependencies> <\/code><\/pre>\n<\/li>\n<\/ul>\n<p>3\u3001\u7f16\u5199\u542f\u52a8\u5f15\u5bfc\u7c7b\uff08Springboot\u9879\u76ee\u8fd0\u884c\u7684\u5165\u53e3\uff09<\/p>\n<p>4\u3001\u7f16\u5199controller\u5c42\u4e1a\u52a1<\/p>\n<p>5\u3001\u542f\u52a8\u9879\u76ee<\/p>\n<h3>3\u3001\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>1\u3001\u521b\u5efa\u9879\u76ee<\/p>\n<p>2\u3001\u5bfc\u5165\u4ee5\u4e0a\u4e24\u4e2a\u4f9d\u8d56\u5728pom.xml\u4e2d<\/p>\n<p>3\u3001\u7f16\u5199\u542f\u52a8\u5f15\u5bfc\u7c7b<\/p>\n<ul>\n<li>\n<p>\u8fd9\u4e2a\u5728main\u65b9\u6cd5\u4e2d\u5199<\/p>\n<\/li>\n<li>\n<p>\u5199\u5b8c\uff0c\u4f1a\u81ea\u52a8\u626b\u63cf\uff0c\u5f15\u5bfc\u7c7b\u4e2d\u7684\u5305\u548c\u5b50\u5305\u7684\u7c7b<\/p>\n<\/li>\n<li>\n<pre><code class=\"language-java\">package com.atguigu;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication \/\/ \u5f00\u542f\u81ea\u52a8\u914d\u7f6e\npublic class Main {\n  public static void main(String[] args) {\n      SpringApplication.run(Main.class,args);\n  }\n}<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>4\u3001\u7f16\u5199controller\u5c42\u4ee3\u7801<\/p>\n<pre><code class=\"language-java\">package com.atguigu.controller;\n\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\npublic class HelloController {\n\n    @GetMapping(&quot;\/hello&quot;)\n    public String hello(){\n        return &quot;Hello,Spring Boot 3!&quot;;\n    }\n\n}<\/code><\/pre>\n<p>5\u3001\u76f4\u63a5\u542f\u52a8\u6d4b\u8bd5<\/p>\n<h2>4\u3001\u603b\u7ed3<\/h2>\n<h3>1\u3001\u4e3a\u4ec0\u4e48\u6211\u4eec\u5bfc\u5165\u7684web\u4f9d\u8d56\u4e0d\u7528\u5199\u7248\u672c\uff1f<\/h3>\n<p>1\u3001\u56e0\u4e3aboot\u9879\u76ee\u7684\u7236\u5de5\u7a0b\u5df2\u7ecf\u5e2e\u6211\u4eec\u5199\u597d\u4e86\uff0c\u4f1a\u4f20\u9012\u4f9d\u8d56<\/p>\n<ul>\n<li>\u6bcf\u4e2aboot\u9879\u76ee\u90fd\u6709\u4e00\u4e2a\u7236\u9879\u76ee<code>spring-boot-starter-parent<\/code><\/li>\n<li>parent\u7684\u7236\u9879\u76ee\u662f<code>spring-boot-dependencies<\/code><\/li>\n<li>\u7236\u9879\u76ee <strong>\u7248\u672c\u4ef2\u88c1\u4e2d\u5fc3<\/strong>\uff0c\u628a\u6240\u6709\u5e38\u89c1\u7684jar\u7684\u4f9d\u8d56\u7248\u672c\u90fd\u58f0\u660e\u597d\u4e86\u3002<\/li>\n<\/ul>\n<h3>2\u3001\u542f\u52a8\u5668\u662f\u4ec0\u4e48\uff08Starter)?<\/h3>\n<p>1\u3001\u6982\u5ff5<\/p>\n<ul>\n<li>Spring Boot\u63d0\u4f9b\u4e86\u4e00\u79cd\u53eb\u505aStarter\u7684\u6982\u5ff5\uff0c\u5b83\u662f\u4e00\u7ec4\u9884\u5b9a\u4e49\u7684\u4f9d\u8d56\u9879\u96c6\u5408\uff0c\u65e8\u5728\u7b80\u5316Spring\u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\u548c\u6784\u5efa\u8fc7\u7a0b\u3002<\/li>\n<li>Starter\u5305\u542b\u4e86\u4e00\u7ec4\u76f8\u5173\u7684\u4f9d\u8d56\u9879\uff0c\u4ee5\u4fbf\u5728\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\u65f6\u81ea\u52a8\u5f15\u5165\u6240\u9700\u7684\u5e93\u3001\u914d\u7f6e\u548c\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p>2\u3001\u4e3b\u8981\u4f5c\u7528<\/p>\n<ul>\n<li>\u7b80\u5316\u4f9d\u8d56\u7ba1\u7406\uff1a\n<ul>\n<li>Spring Boot Starter\u901a\u8fc7\u6346\u7ed1\u548c\u7ba1\u7406\u4e00\u7ec4\u76f8\u5173\u7684\u4f9d\u8d56\u9879\uff0c\u51cf\u5c11\u4e86\u624b\u52a8\u89e3\u6790\u548c\u914d\u7f6e\u4f9d\u8d56\u9879\u7684\u5de5\u4f5c\u3002<\/li>\n<li>\u53ea\u9700\u5f15\u5165\u4e00\u4e2a\u76f8\u5173\u7684Starter\u4f9d\u8d56\uff0c\u5373\u53ef\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u5168\u90e8\u4f9d\u8d56\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u81ea\u52a8\u914d\u7f6e\uff1a\n<ul>\n<li>Spring Boot Starter\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u81ea\u52a8\u914d\u7f6e\u6240\u9700\u7684\u7ec4\u4ef6\u548c\u529f\u80fd\u3002<\/li>\n<li>\u901a\u8fc7\u6839\u636e\u7c7b\u8def\u5f84\u548c\u5176\u4ed6\u8bbe\u7f6e\u7684\u81ea\u52a8\u68c0\u6d4b\uff0cStarter\u53ef\u4ee5\u81ea\u52a8\u914d\u7f6eSpring Bean\u3001\u6570\u636e\u6e90\u3001\u6d88\u606f\u4f20\u9012\u7b49\u5e38\u89c1\u7ec4\u4ef6\uff0c\u4ece\u800c\u4f7f\u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\u53d8\u5f97\u7b80\u5355\u548c\u7ef4\u62a4\u6210\u672c\u964d\u4f4e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u63d0\u4f9b\u7ea6\u5b9a\u4f18\u4e8e\u914d\u7f6e\uff1a\n<ul>\n<li>Spring Boot Starter\u9075\u5faa\u201c\u7ea6\u5b9a\u4f18\u4e8e\u914d\u7f6e\u201d\u7684\u539f\u5219\uff0c\u901a\u8fc7\u63d0\u4f9b\u4e00\u7ec4\u9ed8\u8ba4\u8bbe\u7f6e\u548c\u7ea6\u5b9a\uff0c\u51cf\u5c11\u4e86\u624b\u52a8\u914d\u7f6e\u7684\u9700\u8981\u3002<\/li>\n<li>\u5b83\u5b9a\u4e49\u4e86\u6807\u51c6\u7684\u914d\u7f6e\u6587\u4ef6\u547d\u540d\u7ea6\u5b9a\u3001\u9ed8\u8ba4\u5c5e\u6027\u503c\u3001\u65e5\u5fd7\u914d\u7f6e\u7b49\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u4e13\u6ce8\u4e8e\u4e1a\u52a1\u903b\u8f91\u800c\u4e0d\u662f\u7e41\u7410\u7684\u914d\u7f6e\u7ec6\u8282\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5feb\u901f\u542f\u52a8\u548c\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\uff1a\n<ul>\n<li>Spring Boot Starter\u4f7f\u5f97\u4ece\u96f6\u5f00\u59cb\u6784\u5efa\u4e00\u4e2a\u5b8c\u6574\u7684Spring Boot\u5e94\u7528\u7a0b\u5e8f\u53d8\u5f97\u5bb9\u6613\u3002<\/li>\n<li>\u5b83\u63d0\u4f9b\u4e86\u4e3b\u8981\u9886\u57df\uff08\u5982Web\u5f00\u53d1\u3001\u6570\u636e\u8bbf\u95ee\u3001\u5b89\u5168\u6027\u3001\u6d88\u606f\u4f20\u9012\u7b49\uff09\u7684Starter\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u642d\u5efa\u4e00\u4e2a\u5177\u5907\u7279\u5b9a\u529f\u80fd\u7684\u5e94\u7528\u7a0b\u5e8f\u539f\u578b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6a21\u5757\u5316\u548c\u53ef\u6269\u5c55\u6027\uff1a\n<ul>\n<li>Spring Boot Starter\u7684\u7ec4\u7ec7\u7ed3\u6784\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u7684\u4e0d\u540c\u6a21\u5757\u53ef\u4ee5\u8fdb\u884c\u5206\u79bb\u548c\u89e3\u8026\u3002<\/li>\n<li>\u6bcf\u4e2a\u6a21\u5757\u53ef\u4ee5\u6709\u81ea\u5df1\u7684Starter\u548c\u4f9d\u8d56\u9879\uff0c\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u7684\u4e0d\u540c\u90e8\u5206\u53ef\u4ee5\u6309\u9700\u8fdb\u884c\u5f00\u53d1\u548c\u6269\u5c55\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>3\u3001springboot\u63d0\u4f9b\u7684\u5168\u90e8\u542f\u52a8\u5668\u5730\u5740<\/p>\n<p>1\u3001\u94fe\u63a5\uff1a<a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/using.html#using.build-systems.starters\">Developing with Spring Boot<\/a><\/p>\n<p>4\u3001\u547d\u540d\u89c4\u8303<\/p>\n<ul>\n<li>\u5b98\u65b9\u63d0\u4f9b\u7684\u573a\u666f\uff1a\u547d\u540d\u4e3a\uff1a<code>spring-boot-starter-*<\/code><\/li>\n<li>\u7b2c\u4e09\u65b9\u63d0\u4f9b\u573a\u666f\uff1a\u547d\u540d\u4e3a\uff1a<code>*-spring-boot-starter<\/code><\/li>\n<\/ul>\n<h3>3\u3001@SpringBootApplication\u6ce8\u89e3\u7684\u529f\u6548\uff1f<\/h3>\n<p>1\u3001\u662f\u4e00\u4e2a\u7ec4\u5408\u6ce8\u89e3\u3002\u7ec4\u5408\u4e86\u4ee5\u4e0b\u6ce8\u89e3<\/p>\n<ul>\n<li>@SpringBootConfiguration\n<ul>\n<li>\u6ce8\u89e3\u7c7b<\/li>\n<\/ul>\n<\/li>\n<li>@EnableAutoConfiguration\n<ul>\n<li>\u542f\u52a8springboot\u7684\u81ea\u52a8\u914d\u7f6e\u673a\u5236\u7684\u4f5c\u7528<\/li>\n<\/ul>\n<\/li>\n<li>@ComponentScan\n<ul>\n<li>\u7ec4\u4ef6\u626b\u63cf<\/li>\n<\/ul>\n<\/li>\n<li>public @interface SpringBootApplication {}<\/li>\n<\/ul>\n<p>2\u3001\u603b\u800c\u8a00\u4e4b\uff1a\u4e3b\u8981\u662f\u4e3a\u4e86\u7b80\u5316\u914d\u7f6e\u3002<\/p>\n<ul>\n<li>\u81ea\u52a8\u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\u3001\u626b\u63cf\u5e76\u52a0\u8f7d\u7ec4\u4ef6<\/li>\n<li>\u5c06\u914d\u7f6e\u548c\u626b\u63cf\u5408\u4e8c\u4e3a\u4e00<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001SPringBoot3\u4ecb\u7ecd 1\u3001\u4ecb\u7ecd 1\u3001\u4f7f\u7528\u7248\u672c 1\u3001\u8fd9\u8bfe\u7a0b\u4f7f\u7528SpringBoot\u7248\u672c\uff1a3.0.5 2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-5834","post","type-post","status-publish","format-standard","hentry","category-springboot"],"_links":{"self":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5834"}],"version-history":[{"count":1,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5834\/revisions"}],"predecessor-version":[{"id":5835,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5834\/revisions\/5835"}],"wp:attachment":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5834"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}