spring boot 学习笔记(002) Hello world
来源:互联网 发布:svn 默认端口号 编辑:程序博客网 时间:2024/04/25 13:20
1,在src/main/java下,新建类:
HelloWorld
如下代码:
package springboot;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody; @Controller @EnableAutoConfiguration @SpringBootApplicationpublic class HelloWorld {public static void main(String[] args) {//第一个简单的应用, SpringApplication.run(HelloWorld.class,args);}@RequestMapping("/hello") @ResponseBody public String hello(){ return "Hello World"; } @RequestMapping("/rundemo") @ResponseBody public String demo(){ return "This is demo"; } }
参数 -X clean install
然后 Run
编译通过:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.605 s
[INFO] Finished at: 2016-06-28T13:41:28+08:00
[INFO] Final Memory: 24M/311M
[INFO] ------------------------------------------------------------------------
3,
对HelloWorld.java 右键,点击“Run as ” "Java Appleation"
就启动了
浏览器里,输入:
http://localhost:8080/rundemo
或者
http://localhost:8080/hello
都能看到效果。
0 0
- spring boot 学习笔记(002) Hello world
- Spring-Boot学习笔记一:Hello World
- Spring Boot学习笔记-从Hello World开始 (一)
- Spring Boot学习(简介-Hello World)
- Spring Boot(hello world)
- Spring boot 学习笔记(1)——hello world创建,属性application.properties、 yml配置
- Spring Boot学习入门篇(一)--Hello World
- Spring Boot学习之旅:(一)HELLO WORLD
- Spring学习笔记 Hello World
- 《spring-boot学习》-02-hello world
- Spring Boot学习一Hello World!
- spring-boot-hello-world
- spring-boot Hello World
- hello World Spring Boot
- Spring Boot 学习1--Spring boot起步之Hello World
- Spring Boot快速入门(Hello World)
- spring boot 之 hello world !
- Spring Boot:简单Hello World
- 覆盖拷贝文件夹
- jTable怎么得到选中行的数据
- 获取到Android控件的高度
- javaweb学习总结(三十二)——JDBC学习入门
- 张家口市国学研究会“察哈尔文化城国学大讲堂”暨黄河国学联盟第三届文化沙龙走进张家口活动
- spring boot 学习笔记(002) Hello world
- SlidingMenu实现左侧侧滑效果
- Vivado bug大揭秘——综合实现参数配置中的Bug及解决办法
- chmod指令详细用法
- [Paper 学习笔记]PCANet: A Simple Deep Learning Baseline for Image Classification?
- javaweb学习总结(三十三)——使用JDBC对数据库进行CRUD
- 类名称定义的总结
- Swift NSDate的一个分类,把"Mon Apr 04 19:45:37 +0800 2016"这种格式的时间转换为"2016-04-04 11:45:37 +0000"
- TextSwitcher 使用详解