springboot of Helloworld (a)

  One of the easiest springboot web project pom file as follows:

  

    <-! springboot parent pom file, can be referred to the arbitration center springboot version of the project -> 
    <parent> 
        <groupId> org.springframework.boot </ groupId> 
        <artifactId> springboot-Starter-parent </ artifactId > 
        <Version> 2.2.6.RELEASE </ Version> 
    </ parent> 

    <the Dependencies> 
        <-! springboot project's web quick launcher -> 
        <dependency> 
            <groupId> org.springframework.boot </ groupId> 
            < the artifactId> Starter-Spring-Boot-Web </ the artifactId> 
        </ dependency> 
    </ Dependencies>

  Create a controller class introduced after addition of dependencies corresponding jar package

 

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String sayHello(){
        return "hello springboot!!!";
    }
}

  Creating main entrance of the project

/ ** 
 * denoted a current project springboot item 
 * / 
@SpringBootApplication 
public class HelloApplication { 

    public static void main (String [] args) { 
        SpringApplication.run (HelloApplication.class, args); 
    } 
}

  Note Project Structure

      Class entry application, the controller must be at the top, but can not remember the class entry is written in the top-level application (root directory).

  Of the main program is then run directly

  

    Browser, enter  http: // localhost: 8080 / hello

   

  Thus a simple springboot project created.

  

Guess you like

Origin www.cnblogs.com/onsim/p/12655528.html