In two ways, you can build a spring boot application in five minutes

Snail Internet 2021-01-21 09:38:07
ways build spring boot application


Spring Boot Of course, there is no need to say more about the benefits of , For wanting to engage in Java Friends at work , It's a must learn skill .

in my opinion , Its advantage is Achieve greater, faster, better and more economical results .

  • Multi function , Many common capabilities have integration ;
  • Fast access , A few simple lines of code can complete the access ;
  • Maintain , High community activity , When you have a question, you can find the answer at the first time ;
  • To save money , Free open source projects are naturally the favorite of individuals or enterprises .

Let's talk about it in detail Spring Boot Access tutorial for , It is convenient for readers who have just come into contact with this technology to learn .

Related dependencies

Technology stack :

  • Java 8
  • Maven 3
  • Spring Boot 2.4.2

Environmental Science :

  • operating system :MacOS(Windows Also similar )
  • IDE( Integrated development environment ):IntelliJ IDEA Flagship Edition 2020.1 edition

Spring Boot Project initialization

There are two ways :

  1. Official Website Package
  2. IDE Generate

Official Website Package

Visit the official website :

Specify how the project is built Maven, Choice language Java.

Spring Boot Choose the latest stable version 2.4.2, Project metadata fills in organization and project related information .

The right side depends on choosing the package you will use , Here I have chosen Lombok and Spring Web, The former helps us write less code , The latter supports web Page access , It's convenient for me to do a demonstration .

And then click on the bottom GENERATE Button , The website will automatically generate zip Package and download to local .

After decompressing , We can see the following directory structure .HELP It's a help document ,mvnw It's a program startup command file ,pom Placed project dependencies ,src Contains the source code of the project .

IDE Generate

Access plug in :

  • Get into IntelliJ IDEA Of preferences , stay Plugins Search inside Spring Boot, Check the box , Make plug-ins work .
  • Press the prompt to restart IDE, You can use .


Get into IntelliJ IDEA, Click to create a new project .


choice Spring Initializr, Specify the Java SDK, Choose the default startup mode , This method needs networking , Click next .


By default, you need to fill in the following information , Pictured :


I changed my name , It's called course, This is a project of the tutorial website . At the same time, I put the default Java The version is down to 8, Because I use this version more often .


Click next , What we're seeing is adding dependent pages , Support keyword search , You can choose the dependent package you need . The actual effect is consistent with the official website page , Here I still choose Lombok and Spring Web.


Click next , Set the project name and path , The default name is before Maven In the setup artifact Value , I don't usually change .


Click finish ,IDE Just help us build Spring Boot Project , The file structure is consistent with the package downloaded from our official website .


The project will generate an application startup entry for us , Choose main Method run , This Spring Boot The program will run .

Here is the startup logging , The Red Square in the upper right corner represents running . Click on the Red Square , The console will prompt the program to exit , The upper right corner box will also be grayed out .


Besides using IDE start-up Spring Boot Outside , You can also use project generated command line tools . Navigate to the home directory of the project , Execute the following command (MacOS/Linux):

./mvnw spring-boot:run

Windows The user executes the following command :

mvnw spring-boot:run

You'll see this Spring Boot The whole process of a project from construction to compilation to deployment .



If you want to terminate the application ,Ctrl + C that will do .


The demonstration just now did not involve Web Page , If you want to see the page's access effect , How do you do that ?

add to Web Code

Web Related dependencies we have introduced when we are building projects , So just add the relevant code .

First, navigate to the file, Then add annotations to the startup class @RestController, Add a... At the same time web Access method .

public class CourseApplication {

public static void main(String[] args) {, args);

public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name);


Start at this time Spring Boot, Then open the browser to access http://localhost:8080/hello, You can see the default output . Why is the port 8080 Well ? You go back and look at the screenshot of the startup log , You'll find that the project uses Tomcat Of Web The server ,HTTP The initialization port for is 8080.


Of course, you can also access this with parameters Get request , For example, the following kind of visit .


We can also specify the port by ourselves , Put it in the app configuration file Then you can .

default 8080 It is amended as follows 9090


After restarting the program , Log printing has changed , Browser access also needs to use the newly configured port to access successfully .

Okay , Fast build Spring Boot That's all for the introduction of the application , If it works for you, too , You can give me a compliment , Order one to see , You can also share it with your friends , Thank you very much .

I'm a snail , Crawling on the Internet , See you next time .

本文为[Snail Internet]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云