1. The purpose of this post

From this post on, I would show some questions and answers of springboot interviews.

2. Environments

  • springboot 1.x and 2.x

3. Springboot Interview Questions and Answers Series 1

3.1 How to configure springboot apps by Maven?

There are two ways to do this job, one is by extending from spring-boot-starter-parent:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
</parent>

But if your pom already has a parent, then you can use the dependencyManagement to import springboot artifacts:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

3.2 What’s’ core annotation of springboot? And what’s mainly composed of?

The core annotation is the @SpringBootApplication, it’s composed of these sub-annotations:

  • @SpringBootConfiguration:it’s composed of @Configuration ,implement the auto configuration.

  • @EnableAutoConfiguration:Enable the auto configuration of spring boot apps. You can disalbe some auto configuration options by using exclude like this: @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })。

  • @ComponentScan:Enable the component scan。

To be continued…