Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the three construction methods of SpringBoot project?

Shulou Source: shulou.com Published: 2022-06-02 07:00:38 09月13日 Update

What are the three construction methods of SpringBoot project? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The main purpose of SpringBoot is to simplify the configuration file, through a small number of configurations to run Java programs, its powerful automatic configuration function to help developers easily achieve configuration assembly, through the introduction of SpringBoot starter can achieve the desired functions without the need for additional configuration.

Currently, there are three ways to build a SpringBoot project:

Create a project through Spring Initializr create a project manually through IDEA

Official generation tool

The Spring team provides a very convenient web page for generating SpringBoot projects. Open a browser and enter Spring Initializr:

List of project generation parameters:

Project: project type (Maven and Gradle build tools are supported) Language: main languages of the project can be selected as needed: Java, Kotlin, Groovy SpringBoot:SpringBoot version ProjectMatedata: with Group and Artifact configuration Dependencies: project dependency

Click Generate to download the project when the parameters are set, import the project using IDEA after completion, open the project synchronization and run it.

IDEA creation Project

Newer versions of IDEA have built-in plug-ins to create SpringBoot projects, and the creation principle is also using Spring Initializr to create projects, as shown in the creation process:

Open the IDEA development tool, select file-> new-> project menu, select Spring Initializr in the new dialog box, and click Next to create the SpringBoot project.

Finally, add the main method to start the application:

@ SpringBootApplication@Slf4jpublic class SpringEnvApplication {public static void main (String [] args) {ConfigurableApplicationContext context = SpringApplication.run (SpringEnvApplication.class, args);}}

Manually create a SpringBoot project

In addition to the above two methods, you can also create a SpringBoot project manually, create an empty Maven project through IDEA, and then specify the dependencies of SpringBoot. The basic process is as follows:

Open the IDEA development tool, select file-> new-> project menu in the new dialog box, select Mavenn and click Next to complete the project creation as prompted.

After the project is created, open the pom.xml file and set the parent configuration of pom.xml:

Org.springframework.boot

Spring-boot-starter-parent 2.2.0.RELEASE

Add the SpringBoot Maven packaging plug-in:

Org.springframework.boot

Spring-boot-maven-plugin

Add the main method to start the application:

@ SpringBootApplication@Slf4jpublic class SpringEnvApplication {public static void main (String [] args) {ConfigurableApplicationContext context = SpringApplication.run (SpringEnvApplication.class, args);}}

Complete pom.xml file:

4.0.0

Org.springframework.boot

Spring-boot-starter-parent

2.2.0.RELEASE

Com.csbaic.arch

Spring-env

0.0.1-SNAPSHOT

Spring-env

1.8

Org.springframework.boot

Spring-boot-starter

Org.springframework.boot

Spring-boot-maven-plugin

Once you have set up parent and plug-ins, you can use SpringBoot to create applications.

The answers to the questions about the three construction methods of the SpringBoot project are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Tags: Engineering configuration mode selection tools programs applications manual plug-ins files methods problems help applications development generation functions parameters dialog boxes development tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker Shulou Tech Info Xiaomi OPPO Reno