第一个Spring-boot程序
2017-09-18 13:18
477 查看
首先Pom文件中配置
添加<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> </parent>
将项目配置为继承spring-boot-starter-parent
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
添加一个spring-boot-starter-web依赖关系
编写代码
import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.stereotype.*; import org.springframework.web.bind.annotation.*; @RestController @EnableAutoConfiguration public class Example { @RequestMapping("/") String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(Example.class, args); } }
运行,浏览器访问 localhost:8080 返回Hello World! ok完成
相关文章推荐
- 第一个springboot程序
- SpringBoot系列二:搭建自己的第一个SpringBoot程序
- 使用Intellij创建第一个Springboot程序
- Springboot的第一个程序
- 利用Maven入手Spring Boot第一个程序详解
- 第一个Spring Boot Web程序
- Springboot的第一个Hello World程序
- 第一个 Spring Boot 程序 : 构建 RESTful 服务
- 第一个SpringBoot程序(二)
- SpringBoot入门——我的第一个SpringBoot小程序
- SpringBoot第一个程序
- springboot系列教程(一)——第一个springboot程序
- 第一个 Spring Boot 程序 : 文件上传
- 第一个 spring-boot 程序
- 第一个 Spring Boot 程序
- 【springboot 入门篇】第1篇 第一个spring-boot程序(多种搭建方式)
- 开发第一个Spring Boot 程序
- Spring Boot 第一个HelloWorld程序 whitelabel Error Page
- springboot(1)-springboot第一个程序-helloworld
- 【有配图】Spring Boot 第一个Hello World 程序