In depth analysis of spring boot starter

Introduction to spring boot

The spring framework is very powerful, but even for a very simple project, we have to configure a lot of things. Therefore, there is the spring boot framework. Its function is very simple, which is to help us configure automatically. The core of the spring boot framework is automatic configuration. As long as the corresponding jar package exists, spring will help us configure it automatically. If the default configuration cannot meet the requirements, we can also replace the automatic configuration class and use our own configuration. In addition, spring boot also integrates many useful functions such as embedded web server and system monitoring, so that we can quickly build enterprises and applications.

Dependency management is a key part of any complex project. It's not realistic to implement dependency management manually. You have to spend more time, and the less time you can spend on other important aspects of the project.

Spring boot starter was born to solve this problem. Starter POM is a convenient set of dependency descriptors that you can include in your application. You can get all the one-stop services you need for spring and related technologies without searching and copying and pasting dependencies through sample code.

We have more than 30 boot starters -- some of them are mentioned below.

2、Web Starter

First, let's look at rest service development. We can use libraries like spring MVC, Tomcat and Jackson, which still has many dependencies for a single application.

Spring boot starter helps reduce the number of dependencies added manually by adding a dependency. Therefore, do not specify dependencies manually. You only need to add a starter, as shown below:

Now we can create a rest controller. For simplicity, we will not use the database, but focus on the rest controller:

Genericentity is a simple bean. The type of ID is long and the type of value is string.

That's it. The application is ready to run and you can access it http://localhost:8080/springbootapp/entity/all And check whether the controller works normally.

The latest version of wiser can be found in Maven central warehouse( http://search.maven.org/#search%7Cga%7C1%7Csubethasmtp )Found in.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>