使用Spring Initializer快速创建Spring Boot项目
发布日期:2021-05-10 19:06:32 浏览次数:22 分类:精选文章

本文共 1916 字,大约阅读时间需要 6 分钟。

������Spring Initializer������������Spring Boot������

���������IDE���������Spring Initializer������������Spring Boot���������������������������������������������������������������������Spring Boot IDE������������������������������������������������������

������������������������������������������������������������Spring Boot���������������������������������������������������������������������������������

���������Spring Boot���������������������

src/resources/

  • static: ������������������������������������JavaScript���CSS���������

  • templates: ���������������������������������FreeMarker���Thymeleaf������������

src/main/resources/

  • application.properties: Spring Boot���������������������������������������������������������������������������������

���������������������������������������Spring Boot���������Main class:

package com.example.springboot;

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication public class SpringBoot01HelloworldQuickApplication {

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

}

���������������������Spring Boot-entry point���������������������������������������

������������������������Hello World������������������

package com.example.springboot.controller;

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

@RestController @RequestMapping("/api") public class HelloController {

@GetMapping("/hello")
public String hello() {
return "Hello Spring Boot!";
}

}

������������������������������������������������������������������GET������������ endpoint "/api/hello"���

������������������������������Spring Boot���������������������

上一篇:YAML语法
下一篇:Hello World探究

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2025年04月01日 08时17分58秒