{"id":333,"date":"2022-04-10T09:22:14","date_gmt":"2022-04-10T01:22:14","guid":{"rendered":"https:\/\/blog.lijiajia.top\/?p=333"},"modified":"2026-06-19T17:34:57","modified_gmt":"2026-06-19T09:34:57","slug":"springboot%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%9aspringboot2%e5%85%a5%e9%97%a8%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.ttwow.top\/?p=333","title":{"rendered":"SpringBoot\u5b66\u4e60\u7b14\u8bb0\uff1aSpringBoot2\u5165\u95e8-\u5feb\u901f\u5f00\u59cb(\u4e8c\uff09"},"content":{"rendered":"<p>\u5b98\u7f51\uff1a<a href=\"https:\/\/spring.io\/projects\/spring-boot#learn\"><a href=\"https:\/\/spring.io\/projects\/spring-boot#learn\">https:\/\/spring.io\/projects\/spring-boot#learn<\/a><\/a><br \/>\n\u5feb\u901f\u5f00\u59cb\uff1a<a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/getting-started.html#getting-started.first-application\"><a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/getting-started.html#getting-started.first-application\">https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/getting-started.html#getting-started.first-application<\/a><\/a><br \/>\n\u914d\u7f6e\u6587\u4ef6\uff1a<a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/application-properties.html#appendix.application-properties.json\"><a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/application-properties.html#appendix.application-properties.json\">https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/application-properties.html#appendix.application-properties.json<\/a><\/a><\/p>\n<\/p>\n<h2>\u7cfb\u7edf\u8981\u6c42<\/h2>\n<p>\u25cf Java 8 &amp; \u517c\u5bb9java14 .<br \/>\n\u25cf Maven 3.3+<\/p>\n<h2>maven\u914d\u7f6e<\/h2>\n<pre><code class=\"language-xml\">&lt;mirrors&gt;\n      &lt;mirror&gt;\n        &lt;id&gt;nexus-aliyun&lt;\/id&gt;\n        &lt;mirrorOf&gt;central&lt;\/mirrorOf&gt;\n        &lt;name&gt;Nexus aliyun&lt;\/name&gt;\n        &lt;url&gt;http:\/\/maven.aliyun.com\/nexus\/content\/groups\/public&lt;\/url&gt;\n      &lt;\/mirror&gt;\n  &lt;\/mirrors&gt;\n\n  &lt;profiles&gt;\n         &lt;profile&gt;\n              &lt;id&gt;jdk-1.8&lt;\/id&gt;\n              &lt;activation&gt;\n                &lt;activeByDefault&gt;true&lt;\/activeByDefault&gt;\n                &lt;jdk&gt;1.8&lt;\/jdk&gt;\n              &lt;\/activation&gt;\n              &lt;properties&gt;\n                &lt;maven.compiler.source&gt;1.8&lt;\/maven.compiler.source&gt;\n                &lt;maven.compiler.target&gt;1.8&lt;\/maven.compiler.target&gt;\n                &lt;maven.compiler.compilerVersion&gt;1.8&lt;\/maven.compiler.compilerVersion&gt;\n              &lt;\/properties&gt;\n         &lt;\/profile&gt;\n  &lt;\/profiles&gt;<\/code><\/pre>\n<h2>\u5f15\u5165\u4f9d\u8d56<\/h2>\n<pre><code class=\"language-xml\">    &lt;parent&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n        &lt;version&gt;2.3.4.RELEASE&lt;\/version&gt;\n    &lt;\/parent&gt;\n\n    &lt;dependencies&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n            &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n        &lt;\/dependency&gt;\n    &lt;\/dependencies&gt;<\/code><\/pre>\n<h2>\u521b\u5efa\u4e3b\u7a0b\u5e8f<\/h2>\n<pre><code class=\"language-java\">\/**\n * \u4e3b\u7a0b\u5e8f\u7c7b\n * @SpringBootApplication\uff1a\u8fd9\u662f\u4e00\u4e2aSpringBoot\u5e94\u7528\n *\/\n@SpringBootApplication\npublic class MainApplication {\n\n    public static void main(String[] args) {\n\n        SpringApplication.run(MainApplication.class,args);\n    }\n}<\/code><\/pre>\n<h2>\u7f16\u5199\u4e1a\u52a1<\/h2>\n<pre><code class=\"language-java\">\/\/@Controller\n\/\/@ResponseBody\n@RestController \/\/\u4ee3\u66ff\u4e0a\u9762\u4e24\u4e2a\u6ce8\u89e3\npublic class HelloController {\n\n    @RequestMapping(&quot;\/hello&quot;)\n    public String hello(){\n        return &quot;hello SpringBoot2!&quot;;\n    }\n}<\/code><\/pre>\n<h2>\u7b80\u5316\u914d\u7f6e<\/h2>\n<p>application.properties<\/p>\n<pre><code class=\"language-xml\">server.port=8084<\/code><\/pre>\n<h2>\u542f\u52a8<\/h2>\n<p>\u76f4\u63a5\u8fd0\u884cmain\u65b9\u6cd5<\/p>\n<h2>\u7b80\u5316\u90e8\u7f72<\/h2>\n<pre><code class=\"language-xml\"> &lt;build&gt;\n        &lt;plugins&gt;\n            &lt;plugin&gt;\n                &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n                &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\n            &lt;\/plugin&gt;\n        &lt;\/plugins&gt;\n    &lt;\/build&gt;<\/code><\/pre>\n<p>\u628a\u9879\u76ee\u6253\u6210jar\u5305\uff0c\u76f4\u63a5\u5728\u76ee\u6807\u670d\u52a1\u5668\u6267\u884c\u5373\u53ef\u3002<\/p>\n<p>\u6ce8\u610f\u70b9\uff1a<br \/>\n\u25cf \u53d6\u6d88\u6389cmd\u7684\u5feb\u901f\u7f16\u8f91\u6a21\u5f0f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u7f51\uff1ahttps:\/\/spring.io\/projects\/spring-boot#learn \u5feb\u901f\u5f00\u59cb\uff1aht [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[125],"tags":[69],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-java-backend","tag-springboot"],"_links":{"self":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=333"}],"version-history":[{"count":1,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions"}],"predecessor-version":[{"id":2003,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/333\/revisions\/2003"}],"wp:attachment":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}