Spring Boot profile

SpringBoot simplifies the process of developing spring-based projects by reducing the complexity of configuration, making it a relatively easy task.

SpringBoot itself does not add any new technologies, but integrates some existing frameworks and provides some default configurations that greatly improve our development efficiency. Therefore, before learning to use SpringBoot, it is recommended that you have some basic knowledge of Spring.

SpringBoot greatly simplifies the integration of Spring with other frameworks such as JPA, SpringMvc, Freemaker, Spring Security, etc.

SpringBoot website address: projects. Spring. IO/spring – the boot…

You can check out the latest English documentation for SpringBoot on the website.

Advantages and disadvantages of Spring Boot

1) advantages

  • Build projects quickly.
  • Configuration-free integration with mainstream development frameworks.
  • Projects can run independently without external dependencies on the Servlet container.
  • Provides runtime application monitoring.
  • Greatly improve the efficiency of development and deployment.
  • Natural integration with cloud computing.

2) disadvantages

  • Version iteration speed is very fast, some modules change a lot.
  • Because you do not have to configure yourself, it is difficult to locate errors.
  • There are fewer ready-made solutions online.

Through the above introduction we can simply understand what Is SpringBoot. How to build a Spring Boot application quickly?

Quick setup of Spring Boot

Step 1: Start a new SpringBoot project

IO in the browser, the official website provides us with the initialization page of the Web page. You can select the dependencies you want to use in adding dependencies.

We use Maven as the project build method here. Spring Boot also supports Gradle as the project build tool. The deployment is in the form of a JAR package or, of course, a traditional WAR package. Spring Boot 2.4.4, Spring Boot also supports Groovy language, Kotlin language development, we choose Java as the development language in the application.

Click the “Build” button to download the compressed file, and then unzip it into a folder on your computer.

Step 2: Add code

After opening the project in the IDE and configuring Maven, the dependency download is complete and we can see the basic skeleton of the project.

In our project we implement a /hello Controller interface and print “Hello World” by default. As follows:

@RestController
@SpringBootApplication
public class DemoApplication {

   public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }

   @GetMapping("/hello")
   public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
      return String.format("Hello %s!", name); }}Copy the code

The third step, run

We build and run programs. We can run it either on the command line or directly in IDEA. Run the following command under the directory in your project:

Run from the command line:

MacOS/Linux:

./mvnw spring-boot:run
Copy the code

Windows:

mvnw spring-boot:run
Copy the code

When we see the following log, the last two lines tell us that Spring is up and running.

Spring Boot uses an embedded Apache Tomcat server to act as a Web server and listens for request 8080 on localHostPort. Open your browser and type http://localhost:8080 /hello in the address bar at the top. You should get a nice friendly response like this:

conclusion

SpringBoot is a product of the Spring framework’s best practice of “Convention Over Configuration”. A typical SpringBoot application is essentially an application based on the Spring framework.

This deceptively simple article was a solid foundation from which to start our Spring Boot series.