Spring Boot系列1-helloword

使用springboot簡單輕鬆創建helloword SpringBoot系列1-helloword

關於springboot

這是摘自官方的一段話 Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring applications. 意思是說Spring Boot的設計是以最小的可伸縮的配置讓你的應用程序儘可能快地運行,

爲什麼要使用springboot呢?

影響力大:sping團隊的力作,Spring Boot致力於在蓬勃發展的快速應用開發領域成爲領導者 
簡單:使編碼,配置,部署,監控變簡單 
快速:能夠簡單快速構建好一個項目而不使用太複雜的配置 
自動化:根據你的配置自動導入相關依賴 

實現一個簡單的helloword 

環境:jdk1.8,maven3.1+(非必須)
開發工具:IDE(Eclipse、IntelliJ 或者其它的)

新建一個maven項目,可以是web工程也可以是java基本工程

配置pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
   </dependency>

新建HelloController

    @RestController
    public class HelloController {
        @RequestMapping("/say/{content}")
        public String helloword(@PathVariable("content") String content){
            return content;
        }
    }

SpringbootApplication.java

 @SpringBootApplication
 public class SpringbootApplication {

 	public static void main(String[] args) {
 		SpringApplication.run(SpringbootApplication.class, args);
 	}
 }

運行測試在瀏覽器訪問

http://localhost:8080/say/helloword 可以看到瀏覽器得到返回結果【helloword】

源碼地址:https://github.com/tiankonglanlande/springboot 

作        者:天空藍藍的 
網址導航:http://www.lskyf.com
個人博客:http://www.lskyf.xyz 
版權所有,歡迎保留原文鏈接進行轉載:) 大牛高薪工程師都會那些呢?掃碼關注公衆號瞭解更多!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章