eclipse中搭建springboot学习(2)---第一个helloword项目

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Gr_lbxx/article/details/83106196

打开eclipse,new-Spring Starter Project-next

设置项目名称-next

选择web-next

点击finish即可


写一个controller

package com.example.demo;

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

@Controller
public class HelloController {
    
    @ResponseBody
    @RequestMapping("/hello")
    public String hello() {
        return "spring boot!!!!";
    }
}

 注意:自己写的controller与DemoApplication.java放在同一个包下

运行项目

运行完成后,访问http://localhost:8080/hello既可以看到运行结果

猜你喜欢

转载自blog.csdn.net/Gr_lbxx/article/details/83106196
今日推荐