SpringBoot entry to the master :( a) Hello World

Here Insert Picture Description

Spring Boot Overview

Build Anything with Spring Boot:
Spring Boot is the starting point for building all Spring-based applications. Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring.

The above paragraph is a quote from the official website, you are probably saying: Spring Boot is the starting point for all project-based development of Spring. Spring Boot is designed to get you up and running as quickly as possible and reduce your Spring application configuration file as possible.
Here Insert Picture Description
On SpringBoot official website, introduced SpringBoot features
is fast and easy to create a separate Spring application, and completely without any configuration file
that uses "habit over configuration" A lot of configuration exists (project, in addition to built a habit of configuration, so you do not) ideas to make your project up and running quickly.
It is not a new framework, but the default configuration use a lot of framework, like Maven jar package integrates all the same, Spring Boot incorporates all framework

SpringBoot quickly build

The first step: New Project
Select Spring Initializr, then select the default url click [Next]:
Here Insert Picture Description
then modify information about the project:
Here Insert Picture Description
Check the module project needs
Here Insert Picture Description
to select the project path, modify the project name and click Finish
Here Insert Picture Description
At this point, the project is created, the project structured as follows
Here Insert Picture Description

  • DemoApplication: a class with a main () method, the application for starting
  • DemoApplicationTests: An empty Junit test, and it loads a Spring application using Spring Boot configuration features of the dictionary context
  • resource folder directory structure
    • static: for storing static files (css, js, etc.)
    • templates: templates used to store page
    • application.properties:SpringBoot application configuration file can be used to modify some of the default configuration
  • pom.xml: Maven build documentation

The first step: Hello World
New cn.example.demo] in [the next package a package [controller], [HelloWorldController New Class]:

@RestController
public class HelloWorldController {

    @RequestMapping("/hello")
    public String hello(){

        return "Hello World !!!";

    }
}

The third step: Use IDEA start Spring Boot
us back DemoApplication this class, then right-click on the run:
Here Insert Picture Description

  • Note : The reason we do not project above to manually configure the Tomcat server, because the Spring Boot built Tomcat
    startup success
    Here Insert Picture Description
    can see our Tomcat running on port 8080, we access the "/ hello" Address try:
    Here Insert Picture Description
    At this point , a SpringBoot completion of HelloWorld
Published 40 original articles · won praise 9 · views 20000 +

Guess you like

Origin blog.csdn.net/aawmx123/article/details/102535896