本文介绍如何通过Intellij IDEA创建SpringBoot项目
1、点击Create New Project
2、选择Spring Initialzr,点击Next
3、设置Group、Artifact、Language等信息,点击Next
4、选择依赖,我们先选择Web依赖即可,点击Next
5、命名项目,点击Finish完成
6、修改DemoApplication如下
package com.springboot.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class DemoApplication {
@RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
7、启动应用
8、在浏览器输入http://localhost:8080/