Spring Boot (2) New Spring Boot Project

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.