Eclipse搭建SpringBoot之HelloWorld

eclipse需要先安装Spring Tool Suite™

File -> new -> other

选择starter项目

下一步

下一步

勾选Web,Finish。可以看到项目结构与我们自己建的Maven有些不一样。

新建一个Controller

package com.example.demo;

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

@RestController
public class HelloController {
    @RequestMapping("/hw")
    public String hello() {
        return "Welcome to start SpringBoot!";
    }
}

运行

运行结果

原文地址:https://www.cnblogs.com/linjiqin/p/9513712.html