首页 > 其他分享 >Spring Boot的maven配置

Spring Boot的maven配置

时间:2025-01-01 10:00:57浏览次数:6  
标签:Spring boot springframework maven Boot spring org starter

使用maven,创建Spring Boot项目,做个记录,避免重复今天早上3小时的浪费时间

新版本的配置方法

<?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>3.4.1</version>
<relativePath/>
</parent>
<groupId>org.penguin.study</groupId>
<artifactId>Boot3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Boot3</name>
<description>Boot3</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>3.4.1</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.3</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>



传统版本写法

<?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>
<groupId>org.penguin.study</groupId>
<artifactId>Boot3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Boot3</name>
<description>Boot3</description>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>3.4.1</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.example.demo.Demo2Application</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

标签:Spring,boot,springframework,maven,Boot,spring,org,starter
From: https://www.cnblogs.com/terry-cc/p/18645321

相关文章

  • spring cloud-nacos注册中心入门指南
    注册中心为什么引入注册中心?引入注册中心的主要原因是为了解决微服务架构中服务发现和动态管理的问题。在微服务架构中,服务提供者和消费者之间需要进行远程调用。由于微服务数量众多且动态变化,手动维护服务地址列表不仅效率低下,而且容易出错。注册中心的引入解决了这些问......
  • 成为百万架构师的第一课:设计模式:Spring中的设计模式
    本文原文地址Spring5源码分析一·、Spring中常用的设计模式1.我们通常说的23种经典设计模式:分类设计模式创建型工厂方法(FactoryMethod)、抽象工厂模式(AbstractFacotry)、建造者模式(Builder)、原型模式(Prototype)、单例模式(Singleton)结构型适配器模式(Adapter)、......
  • Spring Boot引起的“堆外内存泄漏”排查及经验总结7
    背景为了更好地实现对项目的管理,我们将组内一个项目迁移到MDP框架(基于SpringBoot),随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因,发现配置了4G堆内内存,但是实际使用的物理内存竟然高达7G,确实不正常。JVM参数配置是“-XX:MetaspaceSize=256M-......
  • spring boot迁移计划 第Ⅰ章 --chapter 1. rust hyper 结合rust nacos-client开发naco
    1.toml依赖nacos_rust_client="0.3"local_ipaddress="0.1"2.代码//todo维护实时服务列表,用来在请求到来时选择转发至具体的服务usestd::sync::Arc;uselog::debug;usenacos_rust_client::client::{naming_client::{Instance,InstanceDefaultList......
  • 聊聊Spring中最常用的11个扩展点
    目录前言1.自定义拦截器2.获取Spring容器对象2.1BeanFactoryAware接口2.2ApplicationContextAware接口2.3ApplicationListener接口3.全局异常处理4.类型转换器5.导入配置5.1普通类5.2配置类5.3ImportSelector5.4ImportBeanDefinitionRegistrar6.项目启动......
  • Spring Boot引起的“堆外内存泄漏”排查及经验总结4
    背景为了更好地实现对项目的管理,我们将组内一个项目迁移到MDP框架(基于SpringBoot),随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因,发现配置了4G堆内内存,但是实际使用的物理内存竟然高达7G,确实不正常。JVM参数配置是“-XX:MetaspaceSize=256M-......
  • Spring Boot引起的“堆外内存泄漏”排查及经验总结5
    背景为了更好地实现对项目的管理,我们将组内一个项目迁移到MDP框架(基于SpringBoot),随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因,发现配置了4G堆内内存,但是实际使用的物理内存竟然高达7G,确实不正常。JVM参数配置是“-XX:MetaspaceSize=256M-......
  • spring boot迁移计划 第Ⅰ章 --chapter 1. rust hyper 结合rust nacos-client开发naco
    1.toml依赖toml="0.8"2.代码由于项目还未完成,部分配置(如数据库等)还未增加,后续更新增加uselog::info;useserde::Deserialize;usestd::{fs,sync::LazyLock};usecrate::init::constant::*;//创建全局静态配置文件staticCONFIG:LazyLock<Config>=LazyL......
  • spring boot迁移计划 第Ⅰ章 --chapter 1. rust hyper 结合rust nacos-client开发na
    1.toml依赖hyper={version="1",features=["full"]}tokio={version="1",features=["full"]}http-body-util="0.1"hyper-util={version="0.1",features=["full"]}2.......
  • Spring Boot引起的“堆外内存泄漏”排查及经验总结5
    背景为了更好地实现对项目的管理,我们将组内一个项目迁移到MDP框架(基于SpringBoot),随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因,发现配置了4G堆内内存,但是实际使用的物理内存竟然高达7G,确实不正常。JVM参数配置是“-XX:MetaspaceSize=256M-......