How to use the Spring boot step by step to build a web-based infrastructure project ... New Project
Select Spring Starter Project
Project name, defined as Moxi
The project selects the web below the Web, then Finesh, and then initializes the associated jar package for the download of MAVEN management.
After the completion of the project structure is as follows:
Operation Engineering
Project--Right key--run as--spring Boot App
If the diagram runs successfully, but it doesn't explain the problem, add a page and a RESTful Web service, create a new package controller and a Admincontroller class, and create a new index.html file under the static folder:
package Com.moxi.controller;
Import Java.util.HashMap;
Import Java.util.Map;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.bind.annotation.RestController;
Import Org.springframework.web.servlet.ModelAndView; @RestController @RequestMapping ("/admin") public class Admincontroller {@RequestMapping (' index ') public Modeland
View Page1 () {return new Modelandview ("/index.html"); @RequestMapping ("map") public map<string, String> Map1 () {map<string, string> map = new H
Ashmap<string, string> ();
Map.put ("name", "John");
Map.put ("Age", "28");
return map; }
}
<! DOCTYPE html>
Re-run Project: Access: Http://localhost:8080/admin/index
Visit: Http://localhost:8080/admin/map
Adding debugging
It's annoying to restart the project every time you modify the code.
Project--Right key--spring tools--add Boot Devtools, then every time you modify the class file will be automatically compiled.
You can also modify Pom.xml to add Devtools dependencies:
Project Address
Https://github.com/daleiwang/moxi
Spring Boot (1) Tool installation:
Http://www.jianshu.com/p/fb6ed37c90eb
Spring Boot (2) New Spring Boot Project
Http://www.jianshu.com/p/00fd73f515f6
Spring Boot (3) Consolidation MyBatis
Http://www.jianshu.com/p/8401e9304fa0
Spring Boot (4) Consolidation Thymeleaf
Http://www.jianshu.com/p/8d2cc7207fb2
Spring Boot (5) A minimalist and complete background frame
Http://www.jianshu.com/p/923d26d705ed
Spring Boot (6) Jar Packaging release
http://www.jianshu.com/p/9cf6faa8595e
Spring Boot (7) War mode packaged publication
http://www.jianshu.com/p/ae170a58f88c