创建Spring Boot 工程

先在eclipse中安装spring -tool -suite插件,然后根据以下步骤可以创建

 

1、新建Spring Starter Project
5



2、Packaging 选择 jar

6



3、勾选Web 项

7



4、项目结构

8


启动项目


1、创建 HelloController.java

9

package com.example.demo;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController 
@RequestMapping("/hello")  
public class HelloController {
    @RequestMapping("/sts")
    public String helloworld(){  
        return "使用spring-tool-suite插件";  
    }  
}


2、运行 DemoApplication.java文件 或者 右键项目 Run As -> Spring Boot App

10



3、打印输出:Started DemoApplication in 3.977 seconds (JVM running for 6.73) 说明项目启动成功。

11



4、访问网页

http://localhost:8080/hello/sts

12

 
 
 
原文地址:https://www.cnblogs.com/kuncy/p/9043432.html