maven toolchains 简单说明
很多时候我们项目可以会包含需要不同jdk 构建,比如有些只能使用jdk8,有些需要使用jdk11,toolchains 可以帮助我们解决此问题
一般玩法
创建一个toolchains.xml 目录,放到home 目录下,里边配置实际需要的jdk 版本(我们的环境可以安装多jdk)
项目构建的时候(使用的插件)使用配置的工具
- 参考配置
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>zulu</vendor>
</provides>
<configuration>
<jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>zulu</vendor>
</provides>
<configuration>
<jdkHome>
</configuration>
</toolchain>
</toolchains>
- 项目使用
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Need to run with Java 8, because `GuavaPatcher` runs too late, and
`com.google.common.base.Stopwatch` has already been loaded. GuavaPatcher
tries to re-define the Stopwatch class in the same classloader, but Java
Java 11 no longer allows this. The existing workaround with that
`GuavaPatcherRunner` runs into the same issue. A proper solution would be
to implement a Java agent, which _is_ allowed to re-define classes.
-->
<jdkToolchain>
<version>1.8</version>
</jdkToolchain>
</configuration>
</plugin>
说明
比如dremio 目前构建就需要配置toolchains,依赖的一些包构建只能使用jdk8
参考资料
https://maven.apache.org/guides/mini/guide-using-toolchains.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2019-12-21 使用threaddump-analyzer 快速查看jvm thread 状态信息
2018-12-21 nginx http2 push 试用
2018-12-21 几个方便进行micro frontend 开发的工具&&类库
2018-12-21 Compoxure example 应用说明
2018-12-21 Compoxure 微服务组合proxy 中间件
2018-12-21 SCS Characteristics
2017-12-21 sqlopsstudio 微软开源跨平台sql server 连接工具