Home>Article>Java> What is the SpringBoot framework? The construction process of SpringBoot framework

What is the SpringBoot framework? The construction process of SpringBoot framework

不言
不言 Original
2018-09-18 15:48:46 14302browse

This article brings you what is the SpringBoot framework? The construction process of the SpringBoot framework has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Introduction to Spring Boot

1. What is SpringBoot

1.1 Spring Boot is a new framework provided by the Pivotal team. It is designed to simplify the initial construction and development process of new Spring applications. The framework uses an ad hoc approach to configuration, eliminating the need for developers to define boilerplate configurations. In this way, Spring Boot is committed to becoming a leader in the booming field of rapid application development.

2. Advantages of SpringBoot

2.1 Removes a large number of xml configuration files

2.2 Simplifies complex dependency management

2.3 Use with various starters, Basically, automated configuration can be achieved

2.4 Quickly start the container

Create independent Spring applications, embedded Tomcat, Jetty containers, without deploying WAR packages, simplifying Maven and Gradle configuration (spring The entrance to the boot project is a main method, just run this method) (If you need to package it, you can directly package it into a jar package, and run java -jar ***.jar)


3. The following application launcher is provided by Spring Boot under the org.spring framework

Spring Boot Building

We all know that in general projects, it is necessary to introduce many packages and many configuration files, which is the most frustrating What's more, in previous projects, it was not enough to just introduce packages, but also to avoid issues such as version conflicts. Generally speaking, it was quite a headache. Then in SpringBoot you no longer need to worry about package versions or missing packages, just a configuration SpringBoot will do it all for us. Let's take a look. Only one core dependency and web support SpringBoot is introduced. Will you help us import which packages? (The following are all the dependencies introduced by this demo)

1. pom.xml configuration

  org.springframework.boot spring-boot-starter-parent 2.0.2.RELEASE     org.springframework.boot spring-boot-starter-web 1.5.9.RELEASE  

2. Program startup entry (directly run the main method) Yes)

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

In order to facilitate testing, we add a Controller and Entity here

import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.firstboot.lpx.entity.Person; @RestController public class MyController { @RequestMapping(value="/getPerson/{age}", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public Person getPerson(@PathVariable int age){ Person p = new Person(); p.setName("小李"); p.setAge(age); return p; } }
public class Person { private String name; private int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }

3. Start the SpringBoot program and access the getPerson interface

#OK, the above is the small demo of SpringBoot.

The above is the detailed content of What is the SpringBoot framework? The construction process of SpringBoot framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn