Eclipse无法找到pom.xml位置 [英] Eclipse not being able to find pom.xml location

查看:233
本文介绍了Eclipse无法找到pom.xml位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的maven项目,我打算使用WebLogic Server进行部署.由于我同样需要一个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(我对此点赞并选择创建一个名为projectnameJARprojectnameWAR甚至projectnameEAR-

I have an existing maven project that I am planning on deploying using WebLogic Server. Since I need an ear file for the same, I am following the steps to create a jar module and a war module which I later plan on including in a parent module. However, when I make a jar module, the moment the folder reflects in eclipse, I get an error regarding the pom.xml. The error says that Project build error: Non-readable POM pom.xml /*ProjectName*JARModule line 1 Maven pom Loading Problem. Any idea why this is happening? The same happens when I try to create a war module as well. And till I dont have those two modules ready, I cannot proceed to making an ear module and including both. Help much appreciated! **UPDATE - ** Here is my parent project pom.xml (On which I right cliked and chose to create a new module named projectnameJAR and projectnameWAR and even projectnameEAR-

    <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>

推荐答案

因此,经过大量的脑筋急转弯,我决定一次切换工作区并进行检查.和ta-daa.就是这样问题解决了.由于某种原因,Eclipse在我当时的工作区中行为异常.我创建了一个新的工作区,并尝试了相同的操作,一切运行顺利.希望这可以帮助. :)

So after a lot of head banging around, I decided to switch my workspace once and check. And ta-daa. That was it. The problem was solved. Eclipse for some reason was misbehaving in the workspace I had then. I created a newer workspace and tried the same thing and everything ran smooth. Hope this helps. :)

这篇关于Eclipse无法找到pom.xml位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆