Create a SpringBoot project

In the websitestart.spring.io/Download the ZIP package and import idea

Create directly in IDEA (select Spring Initializr to create)

The project structure

All packages need to be built in or below the same directory as the main program

For example, if the original package name is com.example.SpringBoot01, all packages should be built under SpringBoot01 or the scan cannot be performed

package com.example.SpringBoot01;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
// Program main entry
@SpringBootApplication
public class SpringBoot01Application {

   public static void main(String[] args) { SpringApplication.run(SpringBoot01Application.class, args); }}Copy the code
Application. Properties is the core configuration file for the Springboot project
Copy the code

Pom. The XML file


      
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
    <! --Springboot project parent project -->
   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.4.3</version>
      <relativePath/> <! -- lookup parent from repository -->
   </parent>
   <groupId>com.example</groupId>
   <artifactId>SpringBoot-01</artifactId>
   <version>0.0.1 - the SNAPSHOT</version>
   <name>SpringBoot-01</name>
   <description>Demo project for Spring Boot</description>
   <properties>
      <java.version>1.8</java.version>
   </properties>
   <dependencies>
       <! All springboot dependencies start with spring-boot-starter -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>
   </dependencies>
<! -- Package plugin -->
   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

</project>
Copy the code

application.properties

Core profile
# Change the port number
server.port=8081
Copy the code

Modifying the startup icon

Create banner.txt under Resources. The information in this file will become the spring startup icon