
{"id":3068,"date":"2021-02-21T09:38:25","date_gmt":"2021-02-21T01:38:25","guid":{"rendered":"http:\/\/127.0.0.2\/?p=3068"},"modified":"2021-02-21T09:38:25","modified_gmt":"2021-02-21T01:38:25","slug":"idea%e4%b9%8b%e6%b2%a1%e6%9c%89%e7%bd%91%e7%bb%9c%e7%9a%84%e6%83%85%e5%86%b5%e4%b8%8b%e5%88%9b%e5%bb%baspringboot%e9%a1%b9%e7%9b%ae","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=3068","title":{"rendered":"Idea\u4e4b\u6ca1\u6709\u7f51\u7edc\u7684\u60c5\u51b5\u4e0b\u521b\u5efaSpringBoot\u9879\u76ee"},"content":{"rendered":"<h2>Idea\u4e4b\u6ca1\u6709\u7f51\u7edc\u7684\u60c5\u51b5\u4e0b\u521b\u5efaSpringBoot\u9879\u76ee<\/h2>\n<p>\u4e00\u4e36\u521b\u5efaSpringBoot\u6709\u4e24\u4e2a\u65b9\u5f0f<br \/>\n1.\u6ca1\u6709\u7f51\u7edc\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528Maven\u521b\u5efa<br \/>\n1.1:\u7528Idea\u521b\u5efamaven\u9879\u76ee \u4e0d\u8981\u52fe\u9009 next<!--more--><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/1.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.2:\u8fd9\u91cc\u586b\u5199\u81ea\u5df1\u7684groupId\u548cartifactid \u7136\u540enext\u5230\u521b\u5efa\u7ed3\u675f<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/2.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.3:\u73b0\u5728\u8fd9\u91cc\u5c31\u662f\u6211\u4eec\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2amaven\u5de5\u7a0b \u73b0\u5728\u6211\u4eec\u5728maven\u5de5\u7a0b\u57fa\u7840\u4e0a \u6dfb\u52a0springboot\u57fa\u7840\u4f9d\u8d56<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/3.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.4:\u6dfb\u52a0\u4ee5\u4e0b\u4f9d\u8d56<\/p>\n<pre>&lt;!--springboot\u57fa\u7840\u7684\u521b\u5efa \u544a\u8bc9maven\u6211\u4eec\u8981\u521b\u5efa\u7684\u662f\u4e00\u4e2aspringboot\u9879\u76ee--&gt;\r\n&lt;parent&gt;\r\n  &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n  &lt;version&gt;2.2.0.RELEASE&lt;\/version&gt;\r\n  &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;\r\n&lt;\/parent&gt;\r\n\r\n&lt;dependencies&gt;\r\n  &lt;!--SpringBook\u6240\u9700\u7684jar\u5305 \u9ed8\u8ba4\u4e0d\u9700\u8981\u5199\u7248\u672c\u53f7 \u7ee7\u627f\u7236\u7c7b\u7684\u7248\u672c\u53f7--&gt;\r\n  &lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-jdbc&lt;\/artifactId&gt;\r\n  &lt;\/dependency&gt;\r\n  &lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;\/artifactId&gt;\r\n  &lt;\/dependency&gt;\r\n  &lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\r\n  &lt;\/dependency&gt;\r\n  &lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\r\n    &lt;scope&gt;test&lt;\/scope&gt;\r\n  &lt;\/dependency&gt;\r\n  &lt;!--Mysql\u4f9d\u8d56 springboot 2.2.0 \u597d\u50cf\u9ed8\u8ba4\u9700\u8981\u4e00\u4e2a\u6570\u636e\u5e93\u8fde\u63a5 \u4e0d\u5199\u4f1a\u62a5\u9519--&gt;\r\n  &lt;dependency&gt;\r\n    &lt;groupId&gt;mysql&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;\r\n    &lt;version&gt;8.0.13&lt;\/version&gt;\r\n  &lt;\/dependency&gt;\r\n&lt;\/dependencies&gt;\r\n&lt;!--spirng \u6253\u5305\u6210war\u5305--&gt;\r\n&lt;build&gt;\r\n  &lt;plugins&gt;\r\n    &lt;plugin&gt;\r\n      &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\r\n    &lt;\/plugin&gt;\r\n  &lt;\/plugins&gt;\r\n&lt;\/build&gt;<\/pre>\n<p>1.5:\u6dfb\u52a0\u5b8c\u6210\u540e\u7684\u6837\u5b50<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/4.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.6:\u7136\u540e\u6211\u4eec\u5728\u9879\u76ee\u4e2d\u521b\u5efa\u4ee5\u4e0b\u76ee\u5f55\u548c\u6587\u4ef6<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/5.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.7:\u7136\u540e\u6211\u4eec\u5728\u76f8\u5e94\u7684\u76ee\u5f55\u4e0b\u521b\u5efa\u542f\u52a8\u7c7b\u548c\u5355\u5143\u6d4b\u8bd5\u7c7b<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/6.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.7.1:\u542f\u52a8\u7c7b\u4ee3\u7801<\/p>\n<pre>package com.aaa.springboot;\r\n\r\nimport org.springframework.boot.SpringApplication;\r\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\r\n\r\n@SpringBootApplication  \/\/\u542f\u52a8\u7c7b\r\npublic class SpringbootApplication {\r\n\r\n    public static void main(String[]args)\r\n    {\r\n        SpringApplication.run(SpringbootApplication.class,args);\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>1.7.2:\u5355\u5143\u6d4b\u8bd5\u7c7b\u4ee3\u7801<\/p>\n<pre>package com.aaa.springboot;\r\n\r\nimport org.junit.jupiter.api.Test;\r\nimport org.springframework.boot.test.context.SpringBootTest;\r\n\r\n@SpringBootTest   \/\/\u5355\u5143\u6d4b\u8bd5\u7c7b\r\npublic class SpringbootTest {\r\n\r\n    @Test\r\n    public void test1()\r\n    {\r\n        System.out.println(111);\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>1.7.3:application.yml\u4e2d\u5bf9\u5e94\u7684\u6570\u636e\u8fde\u63a5<\/p>\n<pre>spring:\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    username: root\r\n    password: 1234\r\n    url: jdbc:mysql:\/\/127.0.0.1:3306\/books?characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=UTC&amp;allowPublicKeyRetrieval=true\r\n<\/pre>\n<p>1.8:\u521b\u5efa\u5bf9\u5e94\u7684controller\u548ctemplates\u6a21\u677f \u4ee5\u53ca\u6211\u4eec\u8bbf\u95eecontroller\u65b9\u6cd5\u8981\u8df3\u5230\u7684\u9875\u9762<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/7.png\" alt=\"\" height=\"538\" \/><\/p>\n<p>1.8.1:controller\u4ee3\u7801<\/p>\n<pre>package com.aaa.springboot.controller;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\n\r\n@Controller\r\npublic class HelloWorldController {\r\n\r\n    @RequestMapping(\"Hellow\")\r\n    public String HellowWord()\r\n    {\r\n        return \"HelloWorld\";\r\n    }\r\n}\r\n<\/pre>\n<p>1.8.2:html\u4ee3\u7801<br \/>\n&lt;!DOCTYPE html&gt;<br \/>\n&lt;html lang=&#8221;en&#8221;&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;meta charset=&#8221;UTF-8&#8243;&gt;<br \/>\n&lt;title&gt;Title&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<\/p>\n<p>\u6b22\u8fce\u4f60\u4f7f\u7528SpringBoot<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>1.9:\u73b0\u5728\u6211\u4eec\u6765\u8fd0\u884c<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2021\/02\/21\/8.png\" alt=\"\" height=\"538\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Idea\u4e4b\u6ca1\u6709\u7f51\u7edc\u7684\u60c5\u51b5\u4e0b\u521b\u5efaSpringBoot\u9879\u76ee \u4e00\u4e36\u521b\u5efaSpringBoot\u6709\u4e24\u4e2a\u65b9\u5f0f 1.\u6ca1\u6709\u7f51\u7edc\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-3068","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/3068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3068"}],"version-history":[{"count":1,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/3068\/revisions"}],"predecessor-version":[{"id":3069,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/3068\/revisions\/3069"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}