简体   繁体   English

Maven安装有效,但是Intellij的构建不起作用

[英]Maven install works but Intellij's build does not

I have the following problem with a multi module maven project: 我在多模块Maven项目中遇到以下问题:

The project was initially created in Eclipse and can be compiled and run there. 该项目最初是在Eclipse中创建的,可以在其中编译和运行。 It also can be built with mvn install . 也可以使用mvn install构建。

Now when I import the project into Intellij using the following import options the parent pom.xml is recognized and the project and its modules are imported. 现在,当我使用以下导入选项将项目导入Intellij时, 识别父pom.xml并导入项目及其模块。

Everything looks fine, but when I try to compile it, one class, that has a class from another module as a dependency, cannot be found. 一切看起来都很好,但是当我尝试编译它时,找不到一个类,该类具有来自另一个模块的类作为依赖项。

I tried a lot of solutions and the ONLY one that worked for me is the outdated maven idea plugin mvn idea:idea as suggested in this thread. 我尝试了很多解决方案,但对我有用的唯一解决方案是线程中建议的过时的maven idea插件mvn idea:idea Now every time something in any of the projects poms changes, I have to rerun mvn idea:idea and hope that it works - otherwise I have to import the whole project again. 现在,每次项目poms中的某些内容发生更改时,我都必须重新运行mvn idea:idea并希望它能起作用-否则,我必须再次导入整个项目。

What am I doing wrong in the import process? 导入过程中我在做什么错? Why does mvn install on the command line work, but building the project in Intellij does not? 为什么在命令行上mvn install工作,但是在Intellij中构建项目却不能呢?

Try to clear the Intellj Cache once by going to File -> Invalidate Caches/Restart click it. 尝试通过转到“文件”->“使缓存无效/重新启动”来清除它,以一次清除Intellj缓存。 You will get an options, In there select Invalidate and Restart. 您将获得一个选项,在其中选择“失效并重新启动”。

Re-import the maven project and compile again it should work. 重新导入Maven项目,然后再次编译即可。

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

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