1 新建项目

新建项目,选择Spring Initializr

【微服务记录】intellij 建立spring boot 项目一路默认,然后选择web

【微服务记录】intellij 建立spring boot 项目

2 代码修改

在java目录下新建controller包,在controller包下新建SampleController类

【微服务记录】intellij 建立spring boot 项目

代码为

package hello;

import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@Controller
@EnableAutoConfiguration
public class SampleController {

    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, args);
    }
}

 

修改配置文件,设置监听端口(默认880)

【微服务记录】intellij 建立spring boot 项目

右键运行

【微服务记录】intellij 建立spring boot 项目

在浏览器登录http://127.0.0.1:9090

【微服务记录】intellij 建立spring boot 项目

相关文章:

  • 2021-05-09
  • 2021-12-04
  • 2021-06-25
  • 2022-12-23
  • 2021-08-02
  • 2021-07-11
  • 2021-08-14
猜你喜欢
  • 2021-11-25
  • 2021-05-28
  • 2021-07-20
  • 2021-12-01
  • 2021-11-03
  • 2021-10-10
  • 2021-06-18
相关资源
相似解决方案