使用 Maven 插件指南

使用 Maven 插件指南

1️⃣ 📦 Maven 默认配置功能
▸ 🏗 默认 Java 17 编译级别
▸ 🔤 UTF-8 源码编码格式
▸ ⚙️ 支持 -parameters 编译参数
▸ 🧩 智能依赖管理(省略版本号)
▸ 🎁 支持 Native 镜像构建
▸ 🛠 包含 Git 提交 ID 等实用插件

⚠️ 注意事项
▸ 🔀 Maven 过滤改用 @..@ 占位符
▸ ⚠️ 修改系统模块需清除 maven.compiler.release


2️⃣ 📜 继承 Starter 父 POM

<!-- 继承Spring Boot默认配置 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.4.5</version>
</parent>

💡 提示:只需在此处指定 Spring Boot 版本

🔧 覆盖依赖版本示例

<properties>
    <slf4j.version>1.7.30</slf4j.version>
</properties>

3️⃣ 🔄 非继承式方案

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>3.4.5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

🔄 手动覆盖版本示例

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.30</version>
</dependency>

4️⃣ ⌨️ 命令行参数

$ mvn spring-boot:run -Dspring-boot.run.profiles=dev,local

⚙️ 配置默认值+覆盖

<properties>
    <app.profiles>local,dev</app.profiles>
</properties>

🔧 运行覆盖

$ mvn spring-boot:run -Dapp.profiles=test

🔗 相关链接
https://docs.spring.io/spring-boot/maven-plugin/packaging.html#packaging.repackage-goal
https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
https://docs.spring.io/spring-boot/appendix/dependency-versions/properties.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值