spring boot helloworld

File -> New -> Project 新建项目

选择要引用的包

设置名字和路径

没有梯子的话有时候会打不开下面页面,打不开话用网页版本创建项目 https://start.spring.io/

新项目maven的配置记得检查下是否配置正确

重新加载maven包后完整的截图

创建controller层


创建HelloController

package com.xx.springdemo.controller;

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

@RestController
public class HelloController {


    @GetMapping("/")
    public String Hello(){
        return "helloworld";
    }
}

直接点击Run开始运行,默认端口是8080,可以在application.properties里改

打开浏览器

猜你喜欢

转载自www.cnblogs.com/nickchou/p/12508239.html
今日推荐