Eclipse 无法找到 pom.xml 位置
Eclipse not being able to find pom.xml location
我有一个现有的 maven
项目,我计划使用 WebLogic
服务器进行部署。因为我需要一个 ear
文件,所以我按照步骤创建一个 jar module
和一个 war module
,我稍后计划将其包含在 parent module
中。但是,当我制作 jar
模块时,文件夹反映在 eclipse
中的那一刻,我收到有关 pom.xml
的错误。错误说 Project build error: Non-readable POM pom.xml /*ProjectName*JARModule line 1 Maven pom Loading Problem
。知道为什么会这样吗?当我尝试创建 war
模块时也会发生同样的情况。在我没有准备好这两个模块之前,我无法继续制作 ear
模块并包括这两个模块。
非常感谢帮助!
**更新 - ** 这是我的 parent project pom.xml
(我右击并选择创建一个名为 projectnameJAR
和 projectnameWAR
甚至 projectnameEAR
- [=34 的新模块=]
<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>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Project_name</name>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version> <!-- Put here the version of your Java EE app, in my case 7.0 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<jersey.version>2.16</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>Project_nameJARModule</module>
<module>Project_nameWARModule</module>
<module>Project_nameEARModule</module>
</modules>
</project>
以下是为 JAR
模块生成的 pom
-
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>Project_nameJAR</groupId>
<artifactId>Project_nameJAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CADJAR</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
以及为 WAR
模块生成的 pom
-
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>Project_nameWAR</groupId>
<artifactId>Project_nameWAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Project_nameWAR Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>Project_nameWAR</finalName>
</build>
</project>
我有一个工作的多模块项目,它与 eclipse 和 weblogic-10.3.6 一起工作。你能确认你有相同的树结构吗?
parent-module
|_module-war
| |_pom.xml
|_module-jar
| |_pom.xml
|_module-ear
| |_pom.xml
|_pom.xml
parent-module/module-ear/pom.xml 看起来像这样。
<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>group-module-ear</groupId>
<artifactId>module-ear</artifactId>
<version>0.0.2</version>
<packaging>ear</packaging>
<parent>
<groupId>group.parent</groupId>
<artifactId>parent</artifactId>
<version>0.0.1</version>
</parent>
<dependencies>
<dependency>
<groupId>group-module-war</groupId>
<artifactId>module-war</artifactId>
<version>0.0.2</version>
<type>war</type>
</dependency>
<dependency>
<groupId>group-module-jar</groupId>
<artifactId>module-jar</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>group-module-war</groupId>
<artifactId>module-war</artifactId>
<bundleDir>/</bundleDir>
</webModule>
<jarModule>
<groupId>group-module-jar</groupId>
<artifactId>module-jar</artifactId>
<bundleDir>/</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
</build>
</project>
parent-module/pom.xml 看起来像这样:
<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>ETIC_J</groupId>
<artifactId>ETIC_J</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<artifactory.url>localhost:8080</artifactory.url>
</properties>
<modules>
<module>module-jar</module>
<module>module-war</module>
<module>metier-etic-ear</module>
</modules>
</project>
你的 pom 似乎没问题,所以这可能是你的 parent pom 和他的孩子之间的路径问题。
parent-module (i.e. your eclipse workspace)
|_Project_nameJARModule
| |_pom.xml
|_Project_nameWARModule
| |_pom.xml
|_Project_nameEARodule
| |_pom.xml
|_pom.xml
这与已发布的 @Aurelien 是同一棵树。
如果您不这样构建树,则必须定义 parent 和模块路径。
工作原理:
<modules>
<module>../path/to/your/child/module/</module>
</modules>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<!-- define the path to the parent -->
<relativePath>../path/pom.xml</relativePath>
</parent>
否则,如果您没有定义特定的树结构,则上面的树结构是默认值<relativePath>
所以在反复思考之后,我决定切换一次我的工作区并检查一下。还有哒哒。就是这样。问题解决了。由于某种原因,Eclipse 在我当时的工作区中出现了异常。我创建了一个更新的工作区并尝试了同样的事情并且一切 运行 顺利。希望这可以帮助。 :)
我有一个现有的 maven
项目,我计划使用 WebLogic
服务器进行部署。因为我需要一个 ear
文件,所以我按照步骤创建一个 jar module
和一个 war module
,我稍后计划将其包含在 parent module
中。但是,当我制作 jar
模块时,文件夹反映在 eclipse
中的那一刻,我收到有关 pom.xml
的错误。错误说 Project build error: Non-readable POM pom.xml /*ProjectName*JARModule line 1 Maven pom Loading Problem
。知道为什么会这样吗?当我尝试创建 war
模块时也会发生同样的情况。在我没有准备好这两个模块之前,我无法继续制作 ear
模块并包括这两个模块。
非常感谢帮助!
**更新 - ** 这是我的 parent project pom.xml
(我右击并选择创建一个名为 projectnameJAR
和 projectnameWAR
甚至 projectnameEAR
- [=34 的新模块=]
<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>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Project_name</name>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version> <!-- Put here the version of your Java EE app, in my case 7.0 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<jersey.version>2.16</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>Project_nameJARModule</module>
<module>Project_nameWARModule</module>
<module>Project_nameEARModule</module>
</modules>
</project>
以下是为 JAR
模块生成的 pom
-
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>Project_nameJAR</groupId>
<artifactId>Project_nameJAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CADJAR</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
以及为 WAR
模块生成的 pom
-
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>Project_nameWAR</groupId>
<artifactId>Project_nameWAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Project_nameWAR Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>Project_nameWAR</finalName>
</build>
</project>
我有一个工作的多模块项目,它与 eclipse 和 weblogic-10.3.6 一起工作。你能确认你有相同的树结构吗?
parent-module
|_module-war
| |_pom.xml
|_module-jar
| |_pom.xml
|_module-ear
| |_pom.xml
|_pom.xml
parent-module/module-ear/pom.xml 看起来像这样。
<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>group-module-ear</groupId>
<artifactId>module-ear</artifactId>
<version>0.0.2</version>
<packaging>ear</packaging>
<parent>
<groupId>group.parent</groupId>
<artifactId>parent</artifactId>
<version>0.0.1</version>
</parent>
<dependencies>
<dependency>
<groupId>group-module-war</groupId>
<artifactId>module-war</artifactId>
<version>0.0.2</version>
<type>war</type>
</dependency>
<dependency>
<groupId>group-module-jar</groupId>
<artifactId>module-jar</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>group-module-war</groupId>
<artifactId>module-war</artifactId>
<bundleDir>/</bundleDir>
</webModule>
<jarModule>
<groupId>group-module-jar</groupId>
<artifactId>module-jar</artifactId>
<bundleDir>/</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
</build>
</project>
parent-module/pom.xml 看起来像这样:
<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>ETIC_J</groupId>
<artifactId>ETIC_J</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<artifactory.url>localhost:8080</artifactory.url>
</properties>
<modules>
<module>module-jar</module>
<module>module-war</module>
<module>metier-etic-ear</module>
</modules>
</project>
你的 pom 似乎没问题,所以这可能是你的 parent pom 和他的孩子之间的路径问题。
parent-module (i.e. your eclipse workspace)
|_Project_nameJARModule
| |_pom.xml
|_Project_nameWARModule
| |_pom.xml
|_Project_nameEARodule
| |_pom.xml
|_pom.xml
这与已发布的 @Aurelien 是同一棵树。 如果您不这样构建树,则必须定义 parent 和模块路径。
工作原理:
<modules>
<module>../path/to/your/child/module/</module>
</modules>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<!-- define the path to the parent -->
<relativePath>../path/pom.xml</relativePath>
</parent>
否则,如果您没有定义特定的树结构,则上面的树结构是默认值<relativePath>
所以在反复思考之后,我决定切换一次我的工作区并检查一下。还有哒哒。就是这样。问题解决了。由于某种原因,Eclipse 在我当时的工作区中出现了异常。我创建了一个更新的工作区并尝试了同样的事情并且一切 运行 顺利。希望这可以帮助。 :)