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

如何强制IntelliJ IDEA使用pom.xml配置运行测试?

解决方案

1. 强制指定Kotlin编译参数

打开File → Settings → Build, Execution, Deployment → Compiler → Kotlin Compiler:

  • 将Target JVM version设置为项目对应的JDK版本(比如1.8,匹配你的kotlin-stdlib-jdk8依赖)
  • 在Additional command line parameters中添加:
    -api-version 1.3 -language-version 1.3
    
  • 若为多模块项目,需确保每个模块的该配置一致,或在Project Structure中统一设置模块的Kotlin版本。

2. 让IntelliJ完全遵循Maven配置

打开File → Settings → Build, Execution, Deployment → Build Tools → Maven → Importing:

  • 勾选Import Maven projects automatically(保证Maven配置自动同步)
  • 取消勾选Override compiler parameters per-module(禁止IntelliJ自行覆盖编译参数)
  • 点击Apply后,右键项目选择Maven → Reload Project重新导入配置。

3. 检查模块级Kotlin配置

打开File → Project Structure → Modules,选中报错的模块(如integration-test):

  • 切换到Kotlin标签页
  • 将Language version和API version都设置为1.3
  • 确认Kotlin standard library选择的是Maven依赖中的版本(而非IntelliJ默认版本)

4. 清理缓存并重启IntelliJ

打开File → Invalidate Caches...,勾选Clear file system cache and local history,点击Invalidate and Restart。重启后重新运行测试即可。


内容的提问来源于stack exchange,提问作者SWiggels

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 15:37:33