You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于所选IntelliJ Profile激活对应Maven Profile?

基于IntelliJ Profile自动激活对应Maven Profile配置方案

需求背景

需要根据所选的IntelliJ运行Profile,自动激活对应的Maven Profile,实现本地测试和服务器部署时加载不同版本的TimesTen依赖:

  • 本地测试:激活local Maven Profile,使用TimesTen 6版本
  • 构建部署:激活server Maven Profile,使用TimesTen 11版本

已配置的Maven Profile

<profiles>
    <profile>
        <id>local</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <org.timesten.version>6</org.timesten.version>
        </properties>
    </profile>
    <profile>
        <id>server</id>
        <properties>
            <org.timesten.version>11</org.timesten.version>
        </properties>
    </profile>
</profiles>

IntelliJ配置步骤

IntelliJ Profile截图说明:界面包含两个自定义运行Profile(Local和Server),需为每个Profile绑定对应Maven Profile

  • 打开IntelliJ的运行/调试配置(Run/Debug Configurations)
  • 选中目标IntelliJ运行Profile(如Local)
  • 切换到构建和运行(Build and run)标签页,找到Maven配置项
  • 在Profiles输入框中填入local,保存配置
  • 重复上述步骤,为Server运行Profile的Profiles输入框填入server

完成配置后,启动对应IntelliJ运行Profile时,Maven会自动激活指定的Profile,加载对应版本的TimesTen依赖。

内容的提问来源于stack exchange,提问作者Jakub Znamenáček

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 08:01:30