Skip to content

Instantly share code, notes, and snippets.

View codeman688's full-sized avatar

Tom the Rat codeman688

View GitHub Profile

Types of SpringBoot application

There are three types of SpringBoot applications:

  • none
  • Servlet-based web application
  • Reactive web application.

Then for the convenience, I posted the code of the relevant class:

Usage of @AliasFor

In Spring's many annotations, it is often found that many different attributes of different annotations play the same role, such as @RequestMapping's value attribute and path attribute. In order to keep their behavior consistent, such as the value of value and the value of path can not conflict, their values should always be equal. To handle these issues uniformly, Spring created the @AliasFor tag.

The @AliasFor tag has the following usage methods.

1, explicit use within the same annotation

For example, the usage in @RequestMapping:

Implement a simple SpringBoot-Starter

We use Spring Boot, which is basically intoxicated by the convenience of its Staters. Starter brings us a lot of automation configuration, with these automated configurations, we can build a production-level development environment with little effort, and some friends will think this Starter is amazing! In fact, Starter is also the basic knowledge point in Spring. Today, codeman will implement a Starter with you, slowly revealing the mystery of Starter!

Core knowledge

A starter generally contains the following:

  • A configuration class annotated with @ConfigurationProperties

An overview of 25 Spring Boot core annotations

We have been learning and applying Spring Boot for some time. How much do you know about Spring Boot annotations? Today I collected the 25 core annotations of Spring Boot, which everyone must master!

1、@SpringBootApplication

This is the most central annotation of Spring Boot. It is used on the Spring Boot main class to identify this as a Spring Boot application that is used to enable Spring Boot. In fact, this annotation is a combination of the three annotations @SpringBootConfiguration, @EnableAutoConfiguration, @ComponentScan. You can also use these three annotations instead of the @SpringBootApplication annotation.

2、@EnableAutoConfiguration

Allow Spring Boot to automatically configure annotations. After opening this annotation, Spring Boot can configure Spring Beans based on packages or classes in the current classpath. For example, if the current classpath has the JAR package of Mybatis, then the @MybatisAutoConfiguration annotation ca

How does SpringBoot start on the command line?

Suppose this is a simple SpringBoot application

20190627231420

If we want to start it, we usually need two steps:

  • Package it into a jar file
  • Run this jar file