“This is the 20th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

Hi, family, I’m bug bug, here I go again. Today we are going to talk about something. OK, let’s continue the series of articles about Ubuntu Zero Basics. Oh, no, no, no, promise not this week; Spring Boot is a very popular framework for Javaer. Spring Boot is a very popular framework for Javaer. I hope you found this series useful!

It has good teaching value. I hope you can gain something from this article. I suggest you collect it first and then read it.

If you think the article is good, please like it, bookmark it, comment on it, and share it together. Remember to give the bug bacteria a three-link with one button

Ok, let’s start the main body of this issue.

One, foreword

  • What is Springboot?

Spring Boot is a new framework from the Pivotal team designed to simplify the initial setup and development process for new Spring applications.

The framework uses a specific way to configure so that developers no longer need to define boilerplate configurations. The way I understand it is that Spring Boot is not a new framework. It has a lot of frameworks configured by default, just like Maven integrates all jars and Spring Boot integrates all frameworks.

  • What are the benefits of using Spring Boot?
  1. Quickly create standalone Spring projects and integrate with mainstream frameworks
  2. Embedded Tomcat does not need to be packaged as a WAR package
  3. The starters automatically rely on version control
  4. Extensive automatic configuration, simplified development, also can change the default values
  5. No XML configuration, no code generation, out of the box

.

In short, it’s an integration of the entire Spring stack to simplify Spring application development, with conventions over configurations and no complexity. Just Run can create a standalone, production-level application.

Said so much, the hand is itching very much, immediately have a try!

Second, the body

A:

** Build maven projects, ** go to the Spring website to get a ready-made demo

  1. start.spring.io/
  2. Select Maven Project, Java, Spring Boot version and some basic Project information. Choose Java version 1.8, as shown in the following figure.

3. Click download directly;

4, then unzip the bug, the bug is using idea editor, click open to open the demo you just downloaded. You can also use your own editor, which I won’t go into here.

Take a look! If the load does not come out, you can choose maven-> refresh

6, below we open the project in the IDE, the IDE used here is IDEA, so a Springboot project is formed, but the disadvantages, some dependence is not configured, then manually add it to it! The directory structure of the project is:

Method 2:

1. You can also build a Springboot demo by hand; For example, use idea, which is very convenient. Choose Spring Initialization to create a SpringBoot project. The following figure

2. Choose the JDK version for your environment. And then all the way next; Finally open; The same as the first one downloaded from the official website; Here is the directory structure;

3. Ok; So we have a directly executable Web application, and then how do we run it? It’s definitely not going to work directly, it’s almost going to boil;

1. Pom plus the following dependencies;

<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>  </dependency> </dependencies>Copy the code

2. Configure the running port number in the configuration file

server.port=8080
Copy the code

3. Select the DemoApplication file and right-click Run Application to directly launch a Web application using embedded Tomcat service requests.

4. The above printing means that the operation is successful;

However, we haven’t provided any controllers to service Web requests, so any path visited will return an error page (commonly called whitelabel Error Page) provided by SpringBoot by default. We can create a new Controller implementation of the service root Web request under the current project:

@RestController
@RequestMapping("/test")
public class TestController {

        @GetMapping( "/hello")
        public String index() {
            return "Hello World!";
    }
}
Copy the code

5, visit http://localhost:8080/test/hello

6, you can see the normal printing of “Hello World! . Proof that the Springboot project is in its infancy. Then you can play it any way you want.

OK, that’s all for this episode. If you have any questions, feel free to comment in the comments section. See you next time.

3. Popular recommendations

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Springboot< 2 >: zero basic entry yamL, properties configuration file introduction and actual use

Springboot< three >: multi-environment switch, profile example demonstration

Springboot< four >: Introduction to stater teaching

Springboot< 5 >: common annotations for Springboot

Springboot< six >:mysql configuration and database query, implement add, delete, change and check

Springboot< seven >: Mybatis -plus entry and actual use to achieve the increase, deletion, change and check

Springboot< 8 >: Mybatis -plus conditional constructor user manual

Springboot< 9 >: Mybatis – Plus custom SQL zero-based teaching

Springboot< ten >: Mybatis XML mapping file >, <= and other special symbols written

. .

If you want to learn more, you can pay attention to the bug bug column “SpringBoot Zero-based Introduction”, from scratch, from zero to one! Hope I can help you.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Be who you want to be, there is no time limit, you can start whenever you want,

You can change from now on, or you can stay the same. There are no rules, and you can be the best version of yourself.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

If this article has been helpful, please put your thumb in the bottom left corner of the article. (# ^. ^ #);

If you like the articles shared by Bug bug, please send bug bug a note! The danjun ‘ᴗ, you guys will have a cameo appearance with you.

If you have any questions about this article, please leave a comment below or join the group [Group number: 708072830].

In view of limited personal experience, all views and technical research points, if you have any objection, please directly reply to participate in the discussion (no offensive comments, thank you);

Copyright notice: This article is the blogger’s original article, reprint please attach the original source link and this article statement, all rights reserved, piracy will investigate! (* ^ del ^ *)