{"id":532,"date":"2025-07-22T12:19:32","date_gmt":"2025-07-22T04:19:32","guid":{"rendered":"https:\/\/www.hgfwq.com\/blog\/?p=532"},"modified":"2025-07-22T12:19:32","modified_gmt":"2025-07-22T04:19:32","slug":"%e4%bb%80%e4%b9%88%e6%98%afspring-boot%e4%bb%a5%e5%8f%8a%e4%b8%ba%e4%bb%80%e4%b9%88%e5%ae%83%e4%bc%9a%e7%ae%80%e5%8c%96java%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e5%bc%80%e5%8f%91","status":"publish","type":"post","link":"https:\/\/www.hgfwq.com\/blog\/532.html","title":{"rendered":"\u4ec0\u4e48\u662fSpring Boot\u4ee5\u53ca\u4e3a\u4ec0\u4e48\u5b83\u4f1a\u7b80\u5316Java\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1"},"content":{"rendered":"<p><p>Spring Boot \u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u6846\u67b6\uff0c\u65e8\u5728\u7b80\u5316\u57fa\u4e8eSpring\u7684\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u3002\u5b83\u63d0\u4f9b\u4e86\u81ea\u52a8\u914d\u7f6e\u3001\u65e0\u4ee3\u7801\u751f\u6210\u548c\u72ec\u7acb\u8fd0\u884c\u7684\u80fd\u529b\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u5feb\u5730\u542f\u52a8\u548c\u8fd0\u884cSpring\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u57fa\u4e8eSpring Boot 2.x\u7248\u672c\uff0c\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684Web\u5e94\u7528\u7a0b\u5e8f\u793a\u4f8b\uff0c\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5feb\u901f\u521b\u5efa\u4e00\u4e2aSpring Boot\u9879\u76ee\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.hgfwq.com\/blog\/wp-content\/uploads\/2025\/07\/gBbxNQz5.jpg\" alt=\"\u4ec0\u4e48\u662fSpring Boot\u4ee5\u53ca\u4e3a\u4ec0\u4e48\u5b83\u4f1a\u7b80\u5316Java\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\" title=\"\u4ec0\u4e48\u662fSpring Boot\u4ee5\u53ca\u4e3a\u4ec0\u4e48\u5b83\u4f1a\u7b80\u5316Java\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\"><\/p>\n<\/p>\n<p><h2>\u4efb\u52a1\uff1a\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Spring Boot Web\u5e94\u7528\u7a0b\u5e8f<\/h2>\n<\/p>\n<p><p>\u672c\u4efb\u52a1\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Web\u5e94\u7528\u7a0b\u5e8f\uff0c\u8be5\u5e94\u7528\u7a0b\u5e8f\u80fd\u591f\u8fd4\u56de\u4e00\u4e2a\u201cHello, World!\u201d\u7684\u6d88\u606f\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907\u6216\u80cc\u666f\u4ecb\u7ecd<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u5b89\u88c5\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<ul>\n<li>Java Development Kit (JDK) 1.8\u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<li>IDE\uff08\u4f8b\u5982IntelliJ IDEA\u3001Eclipse\u6216\u4efb\u4f55\u5176\u4ed6Java IDE\uff09<\/li>\n<li>Maven 3.5\u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<\/ul>\n<p><h2>\u5b8c\u6210\u4efb\u52a1\u6240\u9700\u7684\u8be6\u7ec6\u3001\u5206\u6b65\u64cd\u4f5c\u6307\u5357<\/h2>\n<\/p>\n<p><h3>\u6b65\u9aa4 1\uff1a\u521b\u5efaSpring Boot\u9879\u76ee<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528Spring Initializr\uff08https:\/\/start.spring.io\/\uff09\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Spring Boot\u9879\u76ee\u3002<\/p>\n<\/p>\n<ul>\n<li>\u9009\u62e9Java\u7248\u672c<\/li>\n<li>\u9009\u62e9\u9879\u76ee\u7c7b\u578b\uff08Maven Project\uff09<\/li>\n<li>\u9009\u62e9Spring Boot\u7248\u672c\uff08\u4f8b\u59822.3.4.RELEASE\uff09<\/li>\n<li>\u6dfb\u52a0\u4f9d\u8d56\u9879\uff08\u4f8b\u5982Spring Web Starter\uff09<\/li>\n<li>\u586b\u5199\u9879\u76ee\u4fe1\u606f\uff08\u4f8b\u5982\u7ec4ID\u3001\u827a\u672f\u540d\u79f0\u3001\u63cf\u8ff0\u7b49\uff09<\/li>\n<li>\u70b9\u51fb\u201c\u751f\u6210\u9879\u76ee\u201d\u6309\u94ae<\/li>\n<\/ul>\n<p><h3>\u6b65\u9aa4 2\uff1a\u4e0b\u8f7d\u5e76\u5bfc\u5165\u9879\u76ee\u5230IDE<\/h3>\n<\/p>\n<p><p>\u4e0b\u8f7d\u751f\u6210\u7684.zip\u6587\u4ef6\uff0c\u89e3\u538b\u540e\u5c06\u5176\u5bfc\u5165\u5230\u60a8\u7684IDE\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code>unzip spring-boot-project.zip<\/p>\r\n<p>cd spring-boot-project<\/p>\r\n<p>mvn install<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 3\uff1a\u521b\u5efa\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7c7b<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Java\u7c7b\uff0c\u547d\u540d\u4e3aApplication.java\u3002<\/p>\n<\/p>\n<p><pre><code>public class Application {<\/p>\r\n<p>    public static void main(String[] args) {<\/p>\r\n<p>        SpringApplication.run(Application.class, args);<\/p>\r\n<p>    }<\/p>\r\n<p>}<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 4\uff1a\u521b\u5efa\u63a7\u5236\u5668\u7c7b<\/h3>\n<\/p>\n<p><p>\u5728src\/main\/java\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5305\uff0c\u4f8b\u5982com.example.demo\uff0c\u7136\u540e\u5728\u8be5\u5305\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aController.java\u7684\u7c7b\u3002<\/p>\n<\/p>\n<p><pre><code>package com.example.demo;<\/p>\r\n\r\n<p>import org.springframework.boot.SpringApplication;<\/p>\r\n<p>import org.springframework.boot.autoconfigure.SpringBootApplication;<\/p>\r\n<p>import org.springframework.web.bind.annotation.GetMapping;<\/p>\r\n<p>import org.springframework.web.bind.annotation.RestController;<\/p>\r\n\r\n<p>@SpringBootApplication<\/p>\r\n<p>@RestController<\/p>\r\n<p>public class Controller {<\/p>\r\n\r\n<p>    @GetMapping(\"\/hello\")<\/p>\r\n<p>    public String hello() {<\/p>\r\n<p>        return \"Hello, World!\";<\/p>\r\n<p>    }<\/p>\r\n\r\n<p>    public static void main(String[] args) {<\/p>\r\n<p>        SpringApplication.run(Controller.class, args);<\/p>\r\n<p>    }<\/p>\r\n<p>}<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 5\uff1a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/h3>\n<\/p>\n<p><p>\u5728IDE\u4e2d\u8fd0\u884c\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7c7b\u6216\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code>mvn spring-boot:run<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u6d89\u53ca\u7684\u5173\u952e\u547d\u4ee4\u3001\u4ee3\u7801\u6216\u914d\u7f6e\u793a\u4f8b<\/h2>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5173\u952e\u547d\u4ee4\u548c\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<ul>\n<li>Spring Initializr\uff1ahttps:\/\/start.spring.io\/<\/li>\n<li>Maven\u547d\u4ee4\uff1a`mvn install`<\/li>\n<li>\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7c7b\uff1a`Application.java`<\/li>\n<li>\u63a7\u5236\u5668\u7c7b\uff1a`Controller.java`<\/li>\n<\/ul>\n<p><h2>\u5bf9\u547d\u4ee4\u3001\u4ee3\u7801\u6216\u91cd\u8981\u6982\u5ff5\u7684\u6e05\u6670\u89e3\u91ca<\/h2>\n<\/p>\n<p><p>Spring Initializr\u662f\u4e00\u4e2a\u5728\u7ebf\u5de5\u5177\uff0c\u7528\u4e8e\u5feb\u901f\u751f\u6210Spring Boot\u9879\u76ee\u7684\u57fa\u672c\u7ed3\u6784\u3002Maven\u662f\u4e00\u4e2a\u9879\u76ee\u7ba1\u7406\u5de5\u5177\uff0c\u7528\u4e8e\u6784\u5efa\u3001\u6d4b\u8bd5\u548c\u90e8\u7f72Java\u9879\u76ee\u3002\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7c7b\u662fSpring Boot\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u3002\u63a7\u5236\u5668\u7c7b\u5305\u542b\u5904\u7406HTTP\u8bf7\u6c42\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3001\u6ce8\u610f\u4e8b\u9879\u6216\u76f8\u5173\u7684\u5b9e\u7528\u6280\u5de7<\/h2>\n<\/p>\n<ul>\n<li>\u786e\u4fdd\u5b89\u88c5\u4e86\u6b63\u786e\u7684Java\u7248\u672c\u548cMaven\u7248\u672c\u3002<\/li>\n<li>\u5728\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u4e4b\u524d\uff0c\u8bf7\u786e\u4fddMaven\u5df2\u6b63\u786e\u914d\u7f6e\u3002<\/li>\n<li>\u5982\u679c\u60a8\u9047\u5230\u4efb\u4f55\u9519\u8bef\uff0c\u8bf7\u67e5\u770bMaven\u63a7\u5236\u53f0\u8f93\u51fa\u6216IDE\u7684\u8c03\u8bd5\u8f93\u51fa\u4ee5\u83b7\u53d6\u66f4\u591a\u9519\u8bef\u4fe1\u606f\u3002<\/li>\n<li>\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Spring Boot DevTools\u6765\u7b80\u5316\u70ed\u90e8\u7f72\u548c\u5f00\u53d1\u4f53\u9a8c\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5df2\u7ecf\u6210\u529f\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684Spring Boot Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff01<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot \u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u6846\u67b6\uff0c\u65e8\u5728\u7b80\u5316\u57fa\u4e8eSpring\u7684\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u3002\u5b83\u63d0\u4f9b\u4e86\u81ea\u52a8\u914d\u7f6e\u3001\u65e0\u4ee3\u7801\u751f\u6210\u548c\u72ec\u7acb\u8fd0\u884c\u7684\u80fd\u529b\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u5feb\u5730\u542f\u52a8\u548c\u8fd0\u884cSpring\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u57fa\u4e8eSpring Boot 2.x\u7248\u672c\uff0c\u901a\u8fc7\u4e00&#8230;<\/p>\n","protected":false},"author":1,"featured_media":533,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[260,259,261],"topic":[],"class_list":["post-532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haiwai","tag-boot","tag-spring","tag-261"],"_links":{"self":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/comments?post=532"}],"version-history":[{"count":1,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":535,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/532\/revisions\/535"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media\/533"}],"wp:attachment":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media?parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/categories?post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/tags?post=532"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/topic?post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}