當我發現把最初的一個demo整的面目全非的時候,突然想要找一個簡單的demo做測試,發現與其在原來的上面該,還不如建立一個demo。
官方入門:http://projects.spring.io/spring-boot/
最熟悉maven,這次先做一個maven的demo。

建立maven project。
pom:
View Code
這裡添加了web基礎依賴,模闆為thymeleaf, 添加一個簡單的security配置。
建立src/resources/application.yml:
建立src/resources/application-dev.yml:
建立啟動入口hello.SampleController:
建立一個Controller: hello.HelloController
這裡連個路由。一個指向模闆檔案index,一個傳回json并添加了參數校驗。
需要使用的實體類:hello.entity.User
需要用到的模闆檔案:src/resources/templates/index.html
github: https://github.com/chenxing12/spring-boot-demo
唯有不斷學習方能改變!
-- <b>Ryan Miao</b>