Create spring boot project

1. Create a new Spring Starter Project (need to connect to the external network)

2. Select web

3. Click Finish to generate the maven project

The pom file has some dependencies by default, but an error is reported in one place. The <parent> node reports an error. When you go to the local warehouse to query this dependency, it displays .lastUpdated, so manually copy the dependency of other project warehouses, just fine. 

4. The project directory is as follows

 

5. Add the controller class

package com.htkeystone.dcg.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;



@Controller
public  class DemoController {
    @RequestMapping("/hello")
    String home() {
        return "hello wss";
    }
}

6. Right-click DemoApplication.java---Run As--Java Application, and report an error

Change @Controller to @RestController, ok

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324877222&siteId=291194637