Spring Initializer 快速创建 Spring Boot 项目

1、《Spring Boot 入门》中是使用创建Maven项目,然后导入Spring Boot依赖的方式,虽然相比传统做法已经很快了,但是IDEA等主流Java编辑器都支持快速构建Spring项目

截图如下

生成的项目目录结构

默认项目结构
src/main/java下是源码,主程序 "SpringBoot01HelloworldQuickApplication" 已经生成好了,只需要写我们自己的逻辑业务代码,注意Spring 组件默认必须在主程序同包或者其子包下面

controller在主程序SpringBoot01HelloworldQuickApplication所在包(com.atguigu.springbot)下面


src/main/resources 下是应用资源
static:保存所有的静态资源,如 以前的 js、css、images、音视频文件等;
templates:保存所有的模板页面,注意 Spring Boot 默认 jar 包使用嵌入式的 Tomcat,默认不支持JSP页面);但可以使用模板引擎,如 freemarker、thymeleaf;
application.properties:Spring Boot 应用的配置文件,用来修改Spring Boot 的默认设置,如Tomcat的默认端口号等;
src/test:Maven的测试目录
 

 

package com.atguigu.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;

//这个类的所有方法返回的数据直接写给浏览器,(如果是对象转为json数据)
/*@ResponseBody
@Controller*/
@RestController     //这个注解相当于上面两个注解
public class HelloController {


    @RequestMapping("/hello")
    public String hello(){
        return "hello world quick!";
    }

    // RESTAPI的方式
}

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值