SpringBoot-Introduction and Getting Started-Spring01
Introduction
springboot: Agile development tool
Features:
- No need for template configuration
- When integrating a third-party framework, as long as the corresponding starter dependency package is imported, it can be automatically integrated
- There is only one .properties configuration file by default, xml is not recommended, and .java files will be used to write configuration information later
- When springboot is deployed, the jar package is used, which automatically relies on the Tomcat container internally, providing multi-environment configuration
- The microservice framework springcloud is built on springboot
getting Started
- Select project type (requires networking)
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-mnR1Txty-1599752935869)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910231928542 .png)]
-
project description
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-1x1fW9kz-1599752935871)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910232153780 .png)]
-
Select dependent packages and versions
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-7eZSKwT1-1599752935872)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910232451298 .png)]
-
Modify the dependencies in the pom.xml file, add web after the starter
dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency>
dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
-
Write the controller
-
package com.example.firstspringboot.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @GetMapping("/test") public String test() { return "Hello,SpringBoot"; } }
-
Start the springboot project and run the main method
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-8hSKfzAO-1599752935873)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910234826471 .png)]