Java Maven 错误:模块的 Maven 项目配置不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32013337/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven Error : Maven Project Configuration for Module isn't availabe
提问by Nat
I keep getting this error when I try to compile my code. I have the pom.xml file in my directories but I am not sure if there is something wrong in there. I found only one link on the internet regarding this and that was not my case: Maven project configuration required for module
当我尝试编译我的代码时,我不断收到此错误。我的目录中有 pom.xml 文件,但我不确定那里是否有问题。我在互联网上只找到了一个关于此的链接,这不是我的情况:模块所需的 Maven 项目配置
Error:Maven Resources Compiler: Maven project configuration required for module 'updater' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.
错误:Maven 资源编译器:模块“更新程序”所需的 Maven 项目配置不可用。仅当从 IDE 启动外部构建时才支持编译 Maven 项目。
Here is the content of my pom file:
这是我的 pom 文件的内容:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nothing.updater</groupId>
<artifactId>Updater</artifactId>
<version>1.0-SNAPSHOT</version>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>com.nothing.toolbox</groupId>-->
<!--<artifactId>Toolbox</artifactId>-->
<!--<version>1.1</version>-->
<!--</dependency>-->
<!--</dependencies>-->
</project>
I would really appreciate your help. Thanks!
我将衷心感谢您的帮助。谢谢!
采纳答案by Ojitha
Right click the module and select the Make Module "project module name" option from the pop up menu. The messages will be shown. But go to Problems and see now. This will clear and correct this problem.
右键单击模块并从弹出菜单中选择“制作模块”“项目模块名称”选项。将显示消息。但是转到问题并立即查看。这将清除并纠正此问题。
回答by Lars Gendner
The messages originates from Line 43 in /org/jetbrains/jps/maven/compiler/MavenResourcesBuilder.java, so my guess is that it is no pom.xml issue but rather IntelliJ Idea related.
消息来自/org/jetbrains/jps/maven/compiler/MavenResourcesBuilder.java 中的第 43 行,所以我猜这不是 pom.xml 问题,而是与 IntelliJ Idea 相关。
If you dig further into the code, it looks for a file called maven/configuration.xml
and from what I see, it searches in some temporary directory.
如果您深入研究代码,它会查找一个名为的文件,maven/configuration.xml
并从我看到的内容中搜索某个临时目录。
Maybe you should try and start your build as clean as possible.
也许您应该尝试尽可能干净地开始构建。
回答by user5426077
modify .idea/compiler.xml,add config(should change module name to yourself):
修改.idea/compiler.xml,添加配置(模块名称要自己改):
回答by asmaier
In my case I got this error message, because my Maven configuration in IntelliJ was broken. I had entered invalid options into VM options for importer
at Preferences:Build,Execution,Deployment->Build Tools->Maven->Importing
.
就我而言,我收到此错误消息,因为我在 IntelliJ 中的 Maven 配置已损坏。我在VM options for importer
at 中输入了无效选项Preferences:Build,Execution,Deployment->Build Tools->Maven->Importing
。
After deleting these options IntelliJ started to behave normal again.
删除这些选项后,IntelliJ 再次开始正常运行。
回答by Maksymilian Wojakowski
In my case the problem ocurred after uprgrading IJ from 14.x to 15.x and disappeared when I issued Build -> Rebuild Project
在我的情况下,问题是在将 IJ 从 14.x 升级到 15.x 之后出现的,并且在我发出 Build -> Rebuild Project 时消失了
回答by Dherik
I have the same error after a Intellij Idea version upgrade (2016.3 to 2017.1):
在 Intellij Idea 版本升级(2016.3 到 2017.1)后,我遇到了同样的错误:
Error:Maven Resources Compiler: Maven project configuration required for module 'MODULE_NAKE' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.
错误:Maven 资源编译器:模块“MODULE_NAKE”所需的 Maven 项目配置不可用。仅当从 IDE 启动外部构建时才支持编译 Maven 项目。
But my solution was another. Somehow, I think the Intellij lost the maven version used in my project. I was using maven 2.2.1 but Intellij was trying to use maven 3.x.
但我的解决方案是另一个。不知何故,我认为 Intellij 丢失了我项目中使用的 Maven 版本。我使用的是 maven 2.2.1,但 Intellij 试图使用 maven 3.x。
So, my solution was adjust this configuration in:
因此,我的解决方案是在以下位置调整此配置:
File > Settings > Build, Execution, Deployment > Build Tools > Maven
And set the maven version to 2.2.1.
并将maven版本设置为2.2.1。
回答by Will Brode
I had this problem after an Intellij Idea version upgrade. The fix was to wait for it to finish indexing. Then I think it downloaded some stuff it needed.
Intellij Idea 版本升级后我遇到了这个问题。解决方法是等待它完成索引。然后我认为它下载了一些它需要的东西。
Makes me think that the other answers on this thread about the IJ version upgrade probably just needed to wait as well - by the time they finished trying a few things the problem was fixed by itself.
让我认为该线程上有关 IJ 版本升级的其他答案可能也需要等待 - 当他们完成尝试一些事情时,问题已自行解决。
回答by Pro
Quick solution (IntelliJ IDEA): Right-click on the project, the select Maven->Reimport
快速解决方案(IntelliJ IDEA):在项目上右击,选择Maven->Reimport
回答by Kajzer
Right-click on pom.xml and then click on "Add as Maven Project".
右键单击 pom.xml,然后单击“添加为 Maven 项目”。
回答by ???????
In my case this was caused by a misconfiguration of IntelliJ. A long time ago I had been experimenting with the Lifecycle
options within the Maven Projects
view and had left a few phases in a sub module checked as Execute Before Build
.
就我而言,这是由 IntelliJ 的错误配置引起的。很久以前,我一直在试验视图中的Lifecycle
选项,Maven Projects
并在子模块中留下了几个阶段检查为Execute Before Build
.
Because I had completely forgotten having checked these, it took me quite some time to understand the connection with the error messages in the Problems
view. After unchecking the Execute Before Build
switches of the affected phases everything went back to normal and particularly running unit tests became much faster.
因为我完全忘记了检查这些,所以我花了很长时间才理解与Problems
视图中错误消息的联系。取消选中Execute Before Build
受影响阶段的开关后,一切都恢复正常,尤其是运行单元测试变得更快。