SpringBoot入门学习(一): Idea 创建 SpringBoot 的 HelloWorld
2017-08-16 09:47
429 查看
创建项目:
项目结构:
程序启动入口:
正式开始:
HelloWorld:
控制台显示:
页面显示:
搞定!
项目结构:
程序启动入口:
正式开始:
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @ComponentScan("com.example.helloweb") //扫描所需要的包 public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
HelloWorld:
package com.example.helloweb; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @Controller public class HelloWord { /** * @Controller 和 @ResponseBody 配合相当于 @RestController, * 返回前端页面的都是 json 格式数据。 * @return */ @RequestMapping("/hello") public @ResponseBody String index () { System.out.println("欢迎进入SpringBoot"); return "Hello World!"; } }
控制台显示:
欢迎进入SpringBoot |
搞定!
相关文章推荐
- idea创建spring boot+mybatis(oracle)+themeleaf项目
- IDEA(1)-创建spring boot 的Hello World 项目
- 如何用IDEA创建第一个Spring Boot项目
- 使用idea创建springboot项目并打成war包发布到weblogic上
- 在IDEA中创建跑得起来的Springboot项目
- Spring Boot+Intelli IDEA+Maven创建Hello World
- SpringBoot实践之---JPA连接数据库+idea全新创建该工程
- 使用idea创建springboot项目
- 使用springboot创建第一个helloworld项目
- 使用IDEA+GRADLE创建springboot项目
- idea中创建springboot项目
- IDEA创建第一个springboot项目
- 【系统学习SpringBoot】SpringBoot新建HelloWorld工程(IDEA)
- idea+springboot创建项目
- 使用idea创建SpringBoot项目
- IntelliJ IDEA工具创建入门的springBoot项目
- [SpringBoot学习]-IDEA创建Gradle多Module结构的SpringBoot项目
- 使用IDEA创建一个Spring Boot项目
- 快速创建springboot项目:使用http://start.spring.io/网页创建,使用IDEA的Spring Initializr创建,使用SpringBoot CLI创建