In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge about how to write spingboot programs. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
1. Illustration
Spring further simplifies: SpringBoot-jar: embedded tomacat; micro-service architecture!
What is springboot?
Spring is created to solve the complexity of enterprise application development and simplify development.
Third, how does spring simplify development?
To reduce the complexity of Java development, Spring provides the following four key strategies:
1. Lightweight and least intrusive programming based on pojo
two。 Loose coupling through IOC, dependency injection (DI) and interface-oriented
3. Declarative programming based on AOP and conventions
4. Reduce style code through cuts and templates
IV. Springboot
Springboot is developed based on spring. Springboot itself does not provide the core features and extended functions of the spring framework, but is only used to quickly and agile develop a new generation of applications based on the spring framework. In other words, it is not an alternative to spring, but a tool that works closely with the spring framework to enhance the experience of spring developers. With the core idea that the convention is greater than the configuration, springboot makes a lot of settings for us by default, and most springboot applications need very little spring configuration. At the same time, it integrates a large number of commonly used third-party library configurations (such as Redis, MongoDB, Jpa, RabbitMQ, Quartz, etc.). These third-party libraries in springboot applications can be used almost zero configuration out of the box. So, springboot integrates all the frameworks, it's not a new framework.
The first spingboot program
Environment:
Jdk1.8
Maven 3.8.1
Mysql 5.7
Springboot 2.4.5
Open idea and click File-New-Project
Check spring initializr
Click next
After that, the content is the same as that in maven, and then next.
Then start selecting the needed dependencies. Here we choose the springWeb dependencies in Web, which will help me automatically download some web-related dependencies and import them.
Let's open this SpringbootstudyApplication.
The main entrance of package com.hj.springbootstudy;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;// program! You can't delete or change it, which is equivalent to main! @ SpringBootApplicationpublic class SpringbootstudyApplication {/ / springApplication public static void main (String [] args) {SpringApplication.run (SpringbootstudyApplication.class, args);}}
Found that it is the main function file, we run this main function, we can find that the service has been started!
Then the browser enters localhost:8080
You can see that our web project has been launched!
Under the main function file directory, we create the following familiar folders
Let's take a look at pom.xml 's content.
4.0.0 org.springframework.boot spring-boot-starter-parent 2.4.5 com.hj springbootstudy 0.0.1-SNAPSHOT springbootstudy Demo project for Spring Boot 1.8 org.springframework.boot spring-boot-starter-web Org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin
This includes:
Parent: inherits the dependency management of spring-boot-starter-parent, controls version and packaged content, etc.
Dependencies: the specific dependency of the project. Spring-boot-starter-web is used to implement the HTTP interface (this dependency includes Spring MVC). The official website describes it as: the introduction to building Web (including RESTful) applications using Spring MVC is based on Tomcat as the default embedded container. Spring-boot-starter-test is used to write dependency packages for unit tests.
Build: in the construction configuration part, spring-boot-maven-plugin is used by default. With spring-boot-starter-parent, spring boot applications can be packaged into jar to run directly.
If the spring-boot-starter-web dependency is not imported, you will find that it ends as soon as it is run
These are all the contents of the article "how to write spingboot programs". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.