Spring Boot 项目创建的方式:
    1、通过启动器创建、下载、导入:

    2、通过 idea 继承的工具创建:利用的是上述两个网站的启动器创建项目
    image.png

    Spring Boot 项目依赖管理:
    1、继承 spring-boot-starter-parent:父项目提供了良好的依赖管理,资源过滤和插件配置,同时可以根据需要使用 properties 覆盖其提供的内部依赖

    1. <parent>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactId>spring-boot-starter-parent</artifactId>
    4. <version>2.4.0</version>
    5. <relativePath/> <!-- lookup parent from repository -->
    6. </parent>
    7. <properties>
    8. <!-- 必要时可以通过在此处设置版本号覆盖默认版本 -->
    9. <java.version>1.8</java.version>
    10. </properties>
    11. <dependencies>
    12. <dependency>
    13. <groupId>org.springframework.boot</groupId>
    14. <artifactId>spring-boot-starter-web</artifactId>
    15. </dependency>
    16. <dependency>
    17. <groupId>org.springframework.boot</groupId>
    18. <artifactId>spring-boot-starter-test</artifactId>
    19. <scope>test</scope>
    20. </dependency>
    21. </dependencies>
    22. <build>
    23. <plugins>
    24. <plugin>
    25. <groupId>org.springframework.boot</groupId>
    26. <artifactId>spring-boot-maven-plugin</artifactId>
    27. </plugin>
    28. </plugins>
    29. </build>

    2、导入 spring-boot-dependencies
    父项目:

    1. <packaging>pom</packaging>
    2. <properties>
    3. <java.version>1.8</java.version>
    4. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    5. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    6. <spring-boot.version>2.3.4.RELEASE</spring-boot.version>
    7. </properties>
    8. <dependencyManagement>
    9. <dependencies>
    10. <!-- 不支持通过properties属性进行版本覆盖 -->
    11. <!-- 需要进行版本覆盖时,需要在springboot依赖前引入相应的maven依赖 -->
    12. <dependency>
    13. <groupId>org.springframework.boot</groupId>
    14. <artifactId>spring-boot-dependencies</artifactId>
    15. <version>${spring-boot.version}</version>
    16. <type>pom</type>
    17. <scope>import</scope>
    18. </dependency>
    19. </dependencies>
    20. </dependencyManagement>
    21. <build>
    22. <plugins>
    23. <plugin>
    24. <groupId>org.apache.maven.plugins</groupId>
    25. <artifactId>maven-compiler-plugin</artifactId>
    26. <version>3.8.1</version>
    27. <configuration>
    28. <source>1.8</source>
    29. <target>1.8</target>
    30. <encoding>UTF-8</encoding>
    31. </configuration>
    32. </plugin>
    33. </plugins>
    34. </build>

    模块:

    1. <dependencies>
    2. <dependency>
    3. <groupId>org.springframework.boot</groupId>
    4. <artifactId>spring-boot-starter</artifactId>
    5. </dependency>
    6. <dependency>
    7. <groupId>org.springframework.boot</groupId>
    8. <artifactId>spring-boot-starter-test</artifactId>
    9. <scope>test</scope>
    10. <exclusions>
    11. <exclusion>
    12. <groupId>org.junit.vintage</groupId>
    13. <artifactId>junit-vintage-engine</artifactId>
    14. </exclusion>
    15. </exclusions>
    16. </dependency>
    17. </dependencies>
    18. <build>
    19. <plugins>
    20. <plugin>
    21. <groupId>org.springframework.boot</groupId>
    22. <artifactId>spring-boot-maven-plugin</artifactId>
    23. <version>2.3.4.RELEASE</version>
    24. <configuration>
    25. <!--主配置类 -->
    26. <mainClass>com.example.demo.DemoApplication</mainClass>
    27. </configuration>
    28. <executions>
    29. <execution>
    30. <id>repackage</id>
    31. <goals>
    32. <goal>repackage</goal>
    33. </goals>
    34. </execution>
    35. </executions>
    36. </plugin>
    37. </plugins>
    38. </build>