gpt4 book ai didi

java - 使用 Maven 全新安装某些模块会导致错误 : Error building POM (may not be this project's POM)

转载 作者:行者123 更新时间:2023-12-01 11:06:21 25 4
gpt4 key购买 nike

在路径 C:\PMX\checkout\components\promomax-all_webapps_component 我有这个文件:pom-aggregator-packaging.xml

文件 pom-aggregator-packaging.xml 包含一些使用 turtoiseCVS checkout 的模块。

当我在 cmd 中进入路径 C:\PMX\checkout\components\promomax-all_webapps_component 并输入 mvn -f pom-aggregator-packaging.xml clean install 时,返回的错误为:

+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: unknown

Reason: Could not find the model file 'C:\PMX\checkout\bundles\promomax-spring_aspects'. for project unknown


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Could not find the model file 'C:\PMX\checkout\bundles\promomax-spring_aspects'. for project unknown
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Could not find the model file 'C:\PMX\checkout\bundles\promomax-spring_aspects'. for project unknown
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1575)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:560)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
Caused by: java.io.FileNotFoundException: C:\PMX\checkout\bundles\promomax-spring_aspects (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at hidden.org.codehaus.plexus.util.xml.XmlReader.<init>(XmlReader.java:124)
at hidden.org.codehaus.plexus.util.xml.XmlStreamReader.<init>(XmlStreamReader.java:67)
at hidden.org.codehaus.plexus.util.ReaderFactory.newXmlReader(ReaderFactory.java:118)
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1570)
... 18 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Oct 02 15:46:09 EEST 2015
[INFO] Final Memory: 6M/243M
[INFO] ------------------------------------------------------------------------

pom-aggregator-packaging.xml的内容是:

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.company_name.app_name</groupId>
<artifactId>monitoring-pom-aggregator</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>NameOfTheApp Engine Server Component Pom Aggregator</name>
<modules>
...
<module>../../bundles/promomax-spring_aspects</module>
...
</modules>
</project>

您能帮我解决这个错误吗?

如果在 pom-aggregator-packaging.xml 中我更改了

<module>../../bundles/promomax-spring_aspects</module>给出绝对路径:

<module>C:/PMX/checkout/components/promomax-all_webapps_component/bundles/promomax-spring_aspects</module>

然后我再次运行命令mvn -f pom-aggregator-packaging.xml clean install,新错误是:

[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to canonicalize file name C:\PMX\checkout\components\promomax-all_webapps_component\C:\PMX\checkout\components\promomax-all_webapps_component\bundles\promomax-spring_aspects
The filename, directory name, or volume label syntax is incorrect
[INFO] ------------------------------------------------------------------------

最佳答案

很确定如果你更换

<module>../../bundles/promomax-spring_aspects</module> 

<module>../../components/promomax-all_webapps_component/bundles/promomax-spring_aspects</module> 

它会起作用。

但我觉得你的设置一点也不干净。引用模块通常是从父 POM 完成的,父 POM 应该驻留在比子 pom 更高的级别(文件系统)。

所以就像这样

  • 我的项目
    • 我的模块1
      • pom.xml
    • 我的模块2
      • pom.xml
    • pom.xml(父级)

除非您处于父/子上下文中,否则不应依赖相对路径。

进一步阅读: https://stackoverflow.com/a/10453063/190596

关于java - 使用 Maven 全新安装某些模块会导致错误 : Error building POM (may not be this project's POM),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32908307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com