IDEA使用Spring Initializer快速创建Spring Boot项目(超详细)

举报
牛哄哄的柯南 发表于 2021/05/25 23:58:43 2021/05/25
【摘要】 IDEA使用Spring Initializer快速创建Spring Boot项目(超详细) 创建步骤(需要联网)第一步:New - > Project第二步:选择Spring Initializer第三步:编写相关的包名第四步:选择相应的需求模块第五步:Finish没有必要的文件可以删除resources文件夹中目录结构 运行测试编写controller项...

创建步骤(需要联网)

第一步:New - > Project

在这里插入图片描述

第二步:选择Spring Initializer

在这里插入图片描述

第三步:编写相关的包名

在这里插入图片描述

第四步:选择相应的需求模块

在这里插入图片描述

第五步:Finish

在这里插入图片描述

没有必要的文件可以删除

在这里插入图片描述

我们可以发现:默认生成的Spring Boot项目,主程序已经生成好了,我们只需要编写自己的逻辑。

resources文件夹中目录结构

文件夹 说明
static 保存所有的静态资源如 js css images
templates 保存所有的模板页面;(Spring Boot默认jar包使用嵌入式的Tomcat,默认不支持JSP页 面)可以使用模板引擎(freemarker、thymeleaf)
application.properties Spring Boot应用的配置文件,可以修改一些默认设置

运行测试

编写controller

HelloController:

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

/**
 * Keafmd
 *
 * @ClassName: HelloController
 * @Description:
 * @author: 牛哄哄的柯南
 * @date: 2021-02-22 20:36
 */

/*@ResponseBody //这个类的所有的方法返回的数据直接写给浏览器(如果是对象还能转为json对象)
@Controller*/
@RestController  //等价于上面两个
public class HelloController { @RequestMapping("/hello") public String hello(){ return "Hello World!--quick"; }
}

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

项目目录结构

在这里插入图片描述

启动主程序

在这里插入图片描述

运行结果

控制台输出:


  .   ____ _ __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot :: (v2.4.3)

2021-02-22 21:52:42.268  INFO 24532 --- [ main] s.SpringBoot01HelloworldQuickApplication : Starting SpringBoot01HelloworldQuickApplication using Java 1.8.0_181 on DESKTOP-JISCGLF with PID 24532 (F:\java_workspace\spring-boot-01-helloworld-quick\target\classes started by 章贺龙 in F:\java_workspace\spring-boot-01-helloworld-quick)
2021-02-22 21:52:42.271  INFO 24532 --- [ main] s.SpringBoot01HelloworldQuickApplication : No active profile set, falling back to default profiles: default
2021-02-22 21:52:47.963  INFO 24532 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-02-22 21:52:47.985  INFO 24532 --- [ main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-02-22 21:52:47.985  INFO 24532 --- [ main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.43]
2021-02-22 21:52:48.324  INFO 24532 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-02-22 21:52:48.324  INFO 24532 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 5870 ms
2021-02-22 21:52:49.012  INFO 24532 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-22 21:52:50.745  INFO 24532 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-22 21:52:50.764  INFO 24532 --- [ main] s.SpringBoot01HelloworldQuickApplication : Started SpringBoot01HelloworldQuickApplication in 11.647 seconds (JVM running for 23.219)

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

访问http://localhost:8080/hello
在这里插入图片描述

以上就是IDEA使用Spring Initializer快速创建Spring Boot项目(超详细)的全部内容。

看完如果对你有帮助,感谢点赞支持!
如果你是电脑端的话,看到右下角的 “一键三连” 了吗,没错点它[哈哈]

在这里插入图片描述

加油!

共同努力!

Keafmd

文章来源: keafmd.blog.csdn.net,作者:牛哄哄的柯南,版权归原作者所有,如需转载,请联系作者。

原文链接:keafmd.blog.csdn.net/article/details/113957236

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。