Eclipse创建SpringBoot工程

  1. 首先下载Spring支持插件
  2. 右键新建工程,找到spring boot,双击
  3. 选择springboot版本,2.0.2然后选择web
  4. 点击完成
  5. 等待创建.目录结构如下

  6. package com.example.demo;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;

    @RestController
    @SpringBootApplication
    public class SpringBootDemo2Application {

        @RequestMapping("/")
        String home() {
            return "hello World";
        }
        
        public static void main(String[] args) {
            SpringApplication.run(SpringBootDemo2Application.class, args);
        }
    }
  7. 运行
  8. 访问localhost:8080/



猜你喜欢

转载自blog.csdn.net/ethan__xu/article/details/80546652