Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to treat How Hello World and Hot deployment in Spring Boot 2

Shulou Source: shulou.com Published: 2022-06-02 02:38:09 11月15日 Update

How to treat How Hello World and hot deployment in Spring Boot 2? I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

We have built a program for HelloWorld. Now, let's take a look at this program. Here are the points we will analyze in this section.

Spring-boot-starter-boot

@ SpringBootApplication

Thermal loading

Spring-boot-starter-boot

Our program is built using maven. If we look at the pom.xml file, we can see that it inherits from this pom, which is a unique part of Maven. What's the use of it?

Java 1.8 is the default compiler level.

UTF-8 coding.

A dependency management section that inherits from spring-boot-dependencies pom and manages versions of generic dependencies. This dependency management can be omitted when using these dependencies in your own pom

< version>

Mark.

Reasonable plug-in configuration (exec plug-ins, git commit id and shade, etc.). I won't talk about it any more. If you want to know more about it, you can send it to see it.

Reasonable resource filtering (e.g. application.properties and application.yml). Contains profile-specific files (for example: application-dev.properties and application-dev.yml)

@ SpringBootApplication

When we look at the BootApplication startup class, we can see that there is a note on the startup class like this:

With an inquisitive attitude, let's take a look at what is included in this annotation class:

You can find that this annotation is composed of multiple annotations (@ SpringBootConfiguration,@EnableAutoConfiguration,@ComponentScan). When SpringBootApplication starts, it scans the current package and subpackages of the main class by default. If you need to scan other packages outside the current package of the main class or do not scan specific packages or classes under the current package, you can set it through the enclosed properties above.

Now let's add this configuration and hold down the ctrl key to locate the package. If we set the property of exclude, we will not add this class to the container managed by Spring. One thing to note here is that the class of exclude must be a class of auto-configuration, otherwise the startup will report an error. As for what auto-configuration is, we will explain it later.

Thermal loading

Next, I would like to introduce a development tool: DevTools, it can greatly improve the efficiency of our development, so how to use it in the environment of IDEA?

Step 1: add dependencies

Step 2: configure the listening path in the configuration file (which can be omitted):

Step 3: change the IDEA settings: first open the settings window and make the following settings

Then, go back to the page and press Ctrl + Shift + Alt + / (Command + Shift + Option + / under Mac), and the following page will appear:

After clicking Registry, the following page will appear for configuration:

Even if it's done here, it's done.

That's all for this article, and we'll continue next week.

The original article is limited in style and shallow in learning. If there are any irregularities in the article, please let me know.

Cloud stroking cat

After reading the above, have you mastered how to view How Hello World and hot deployment in Spring Boot 2? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Configuration files annotations management programs problems pages content properties plug-ins methods more development incorrect big get to the bottom of the matter get to the bottom of the matter get to the bottom of it have little tal Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS vpn MySQL MariaDB