helloworld(springboot maven)

Environmental preparation

windows environment

  1. intellij idea ultimate 2018.1
  2. jdk1.8
  3. springboot 2.6.7

start

insert image description here
insert image description here
By default, no dependencies are selected, and the springboot version is 2.6.7
insert image description here

insert image description here
click finish

Project initial directory structure

insert image description here
1.main\java\com\fqcheng220\helloworldspringboot\HelloworldSpringbootApplication.java

package com.fqcheng220.helloworldspringboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HelloworldSpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(HelloworldSpringbootApplication.class, args);
    }

}

2. The content of the main/resources/application.properties file is initially empty

3.pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.7</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.fqcheng220</groupId>
    <artifactId>helloworld-springboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>helloworld-springboot</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

run

Maven automatically imports the dependencies of the pom configuration. After completion, click the green triangle run to run ok
insert image description here

problems encountered

Native pom nested dependency download failed

Solution: Delete the corresponding package in the m2 cache, and click refresh to download the dependencies again in the side window of the maven project

おすすめ

転載: blog.csdn.net/weixin_41548050/article/details/124641284