简体   繁体   English

Intellij 无法解析传递依赖

[英]Intellij can't resolve transitive dependencies

I have weird issue, mvn clean install -Dproject.version=1 or jenkins build is going through fine but intellij is all red and angry when i open the modules in IDE, this affects the development.我有一个奇怪的问题, mvn clean install -Dproject.version=1jenkins build 运行正常,但是当我在 IDE 中打开模块时,intellij 全是红色和生气,这会影响开发。

I see below issue in intellij logs我在 Intellij 日志中看到以下问题

The POM for << module >> is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details << 模块 >> 的 POM 无效,传递依赖项(如果有)将不可用,启用调试日志以获取更多详细信息

Code is heavily copyrighted so cant disclose but here is a basic outline代码受版权保护,所以不能透露,但这里是一个基本大纲

  • fabric-common : base module ( common fabric to bind entire project , contains all clients and db modules ) - lets call it FC fabric-common :基本模块(绑定整个项目的通用结构,包含所有客户端和数据库模块)——我们称之为FC
  • utilities : module in question ( import s FC ) and uses db modules - lets call utilities U实用程序:有问题的模块( import s FC )并使用 db 模块 - 让我们调用实用程序U

Now U is all red because it cant find DAO's of db, if U s POM explicitly contains db modules every one is happy.现在U都是红色的,因为它找不到 db 的 DAO,如果U的 POM 明确包含db模块,每个人都很高兴。

Auto-Import on intellij is enabled, imports are happening on maven3 , and local repository is all updated with correct version too.在 intellij 上启用Auto-Import在 maven3 上进行maven3 ,并且本地存储库也全部更新为正确的版本。

Is this a known issue or any help around?这是一个已知问题还是任何帮助?

Intellij details Intellij 详细信息

在此处输入图片说明

Edit编辑

Question suggested as duplicate is an issue specific to maven not able to resolve dependencies but in my case, maven build from command line or jenkins is fine but IDE fails.建议重复的问题是maven无法解决依赖项的特定问题,但在我的情况下,从命令行或 jenkins 构建maven很好,但 IDE 失败。

you can try to你可以尝试

  • invalidate cache an restart使缓存无效重新启动
  • delete .iml and .ipr files删除.iml.ipr文件
  • clean up Project structure (if I recall correctly) Libraries or Artifacts.清理Project structure (如果我没记错的话)库或工件。 Just delete them, so they get updated via Maven.只需删除它们,这样它们就可以通过 Maven 进行更新。
  • run mvn idea:idea运行 mvn idea:idea

in arbitrary order.以任意顺序。 I cannot recall which one it was, but I'd place my bets on .ipr / .iml , clean up Project structure and Invalidate restart我不记得它是哪一个,但我将赌注放在.ipr / .iml ,清理Project structureInvalidate restart

Edit编辑

here is what worked这是有效的


ensure intellij is open before we start doing this ( needed to invalidate cache in step 3 ) and you have setup maven3 as home directory ( Preferences -> Build, Execution, Deploymnet -> Maven : Maven Home directory )在我们开始执行此操作之前确保 intellij 处于打开状态(需要在步骤 3 maven3缓存无效)并且您已将maven3设置maven3目录( Preferences -> Build, Execution, Deploymnet -> Maven : Maven Home directory

delete all iml, ipr, iws删除所有 iml、ipr、iws

cd <parent dir of project>
find project/ -type f -name "*iml*" -exec rm {} \;
find project/ -type f -name "*ipr*" -exec rm {} \;
find project/ -type f -name "*iws*" -exec rm {} \;

remove local repository删除本地存储库

   cd ~/.m2
   mv repository* ~/Desktop/

:: close the intellij project window ( not intellij, just project window ) :: 关闭 Intellij 项目窗口(不是 Intellij,只是项目窗口)

:: invalidate cache and restart ( this would close intellij and restart with blank screen) :: 使缓存无效并重新启动(这将关闭 Intellij 并以空白屏幕重新启动)

:: once intellij opens, open the project by selecting project level POM ( this would re-import all dependencies in local again - one we deleted in step 4 ) :: 一旦 intellij 打开,通过选择项目级别 POM 打开项目(这将再次重新导入本地中的所有依赖项 - 我们在步骤 4 中删除的一个)

cd < project path >

:: run ( in intellij terminal if possible - being superstitious here 😅 ) - this would update local intellij: :: 运行(如果可能,在 intellij 终端中 - 在这里迷信😅) - 这将更新本地智能:

mvn -U idea:idea -Dproject.version=1.0

:: right click on pom.xml of specific project, Maven -> Reimport :: 右键单击​​特定项目的 pom.xml, Maven -> Reimport

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM