Springboot 入门创建hello world1!

1、首先使用工具是Eclipse,安装插件,点击“Help”-“Eclipse Marketplace...”,

一步步直接Ok,等待安装完成

2、创建Springboot项目

到此 就创建成功了

3、创建一个Controller

package com.example.demo.controller;

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

@RestController
@RequestMapping(value="/test")
public class TestController {

    @RequestMapping("/hello")
    String hello() {
        return "hello world1!";
    }
    
    @RequestMapping("")
    String index() {
        return "Eclipse  创建的springboot 项目";
    }
    
    @RequestMapping("/index")
    String index1() {
        return "index";
    }
    
    
}

4、右键项目“”Run As”选择“spring boot app”,运行结果

代表启动成功

自带tomcat,默认是8080端口

猜你喜欢

转载自www.cnblogs.com/zwdx/p/9087209.html