In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what is the application method of Spring Boot". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Preface
The reason for the emergence of Spring Boot
The emergence of Spring Boot is mainly used to solve some problems of Spring in the past, put forward the idea that agreement is better than configuration, and set many methods by default, so that developers can quickly build projects and integrate third-party content. The development efficiency is greatly improved.
Basic concept
Spring Boot is not only a framework, but also a system designed to simplify the development of Spring.
Characteristics
Spring-based development provides faster getting started, and redundant code does not simplify Spring without built-in containers
Core functions rely heavily on build tools for automated configuration
Hello World
Maven creation
Create a new empty project and create a module respectively, as shown in the following figure
Create Maven Module
Create a Module, select the Maven project, and check the previously used web skeleton
Fill in the GroupID,ArtifactID
After making your choice, press and press enter.
This completes the creation of a basic maven project
Add start-up dependency
According to the requirements of Spring Boot, simple testing and adding corresponding start-up dependent projects need to inherit Spring Boot start-up rely on Spring boot starter parent in order to integrate Spring MVC for Controller development, you need to import Spring boot starter web
4.0.0 org.springframework.boot spring-boot-starter-parent 2.2.7.RELEASE cn.ideal springboot_01_start 1.0-SNAPSHOT org.springframework.boot spring-boot-starter-web
Write Spring Boot startup classes
Here you write the Spring Boot startup class
Package cn.ideal; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @ SpringBootApplication public class MySpringBootApplication {public static void main (String [] args) {SpringApplication.run (MySpringBootApplication.class);}}
Create a control layer
Package cn.ideal.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @ Controller public class QuickStartController {@ RequestMapping ("/ test") @ ResponseBody public String test () {return "springboot access test, take off, fly ~";}}
Test Spring Boot
When the project starts, the console will output the following
. _ _ _ / / _ _ _ (_) _ (() _ _ _ | | |. _ | _ | | _ | _ | | _ _ | | / = | _ | = | _ _ / = / _ /:: SpringBoot:: (v2.2.7.RELEASE) 2020-05-10 22 INFO 11purl 34.973 INFO 30580-[main] cn.ideal.MySpringBootApplication: Starting MySpringBootApplication on LAPTOP-5T03DV1G with PID 30580 (F:developIdeaProjectsframework-codespringboot_01_demospringboot_01_starttargetclasses started by abc in F:developIdeaProjectsframework-codespringboot_01_demo) 2020- 05-10 22 cn.ideal.MySpringBootApplication 1115 34.976 INFO 30580-[main] cn.ideal.MySpringBootApplication: No active profile set Falling back to default profiles: default 2020-05-10 22 11 INFO 35.686 INFO 30580-[main] o.s.b.w.embedded.tomcat.TomcatWebServer: Tomcat initialized with port (s): 8080 (http) 2020-05-10 22 22 11 Starting service 35.693 INFO 30580-[main] o.apache.catalina.core.StandardService: Starting service [Tomcat] 2020-05-10 22 11 INFO 30580 [main] org.apache.catalina.core.StandardEngine: Starting Servlet engine: [Apache Tomcat/9.0.34] 2020-05-10 22 INFO 1115 35.765 INFO 30580-[main] o.a.c.c.C. [tomcat]. [localhost]. [/]: Initializing Spring embedded WebApplicationContext 2020-05-10 2211 INFO 35.766 INFO 30580-[main] o.s. Web.context.ContextLoader: Root WebApplicationContext: initialization completed in 747 ms 2020-05-10 22 11 INFO 35.884 INFO 30580-[main] o.s.s.concurrent.ThreadPoolTaskExecutor: Initializing ExecutorService 'applicationTaskExecutor' 2020-05-10 22 initialization completed in 11 main 35.990 INFO 30580-[main] o.s.b.w.embedded.tomcat.TomcatWebServer: Tomcat started on port (s): 8080 (http) with context path'' 2020-05-10 22 INFO 1115 35.993 INFO 30580-[main] cn.ideal.MySpringBootApplication
The picture is shown as follows
Enter the controller project you created and print it directly.
The project is packaged as a jar package
Add dependency
Org.springframework.boot spring-boot-maven-plugin
Click on the right, package to package, and select the package option
You can see that a new jar package is generated under target, which runs directly in cmd.
This is the end of the content of "what is the Application method of Spring Boot". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.