一步一步教你在IEDA中快速搭建SpringBoot项目

场景

IEDA 2017

现在要在IDEA中搭建SpringBoot项目快速输出HelloWorld。

实现

打开IEDA,点击File--new--project

选择左边的Spring Initializr,注意右边这里默认是1.8,其他不变,点击next。

编写Group、Artifact,这里使用默认的,点击next。

点击左边Web,然后勾选右边Web,点击Next。

设置好项目名以及项目路径,点击Finish。

点击FInish后会进行下载一些资源文件。

建完成后的目录如下

在项目下新建包

新建包之后

在新建的包下面新建controller。

建成之后的Controller如下

修改其代码为:

package com.example.demo.controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
/**
 * Created by BADAO on 2019/2/19.
 */
@RestController
public class TestController {
    @RequestMapping("/test")
    public  String hello(){
        System.out.print("Hello Spring Boot!!!!!!!");
        return  "I am Idea!!!!";
    }
}

打开Application

修改其代码为:

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@SpringBootApplication
@EnableAutoConfiguration
public class DemotestApplication {

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

}

右击Application,运行

运行后输出如下

打开浏览器,输入:

http://localhost:8080/test

可以看到控制台输出

而浏览器会显示

猜你喜欢

转载自blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/87688277