开始第一个Spring Boot,在web浏览器输出Hello,感受快速开发。
1、建立Maven项目,pom.xml
文件代码如下:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
2、编写运行代码
@RestController
@EnableAutoConfiguration
public class DemoApplication {
@RequestMapping("/")
String home() {
return "Hello World!(世界 你好)";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
3、运行2代码后,在浏览器输入localhost:8080
浏览器显示内容(支持中文哦):Hello World!(世界 你好)