Spring Boot的快速创建

一、利用向导快速搭建Spring Boot应用

创建一个controller

package com.hoje.springboot.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/*@RequestBody
@Controller*/
@RestController
public class HelloController {
    @RequestMapping("/hello")
    public  String hello(){
      return "hello world quick";
    }
}
HelloController

 

默认生成的Spring Boot项目:

1、主程序已经生成好了,只需要添加我们自己的逻辑;

2、resource文件夹目录结构

  • static :保存所以的静态资源:js css images;
  • templates:保存所以的模板页面:(Spring Boot默认jar包使用嵌入式Tomcat,默认不支持JSP页面,可以使用模板引擎(freemaker,thymeleaf));
  • application.properties:Spring Boot应用的配置文件;
server.port=8081

          可以修改一些默认的配置

原文地址:https://www.cnblogs.com/hoje/p/10736683.html