【问题标题】:Import maven project but parent module disabled导入 maven 项目但禁用父模块
【发布时间】:2014-01-02 20:10:05
【问题描述】:

我想在我的 ecplise 工作区中导入这个项目: https://github.com/steinsag/gwt-maven-example

项目的结构是:

  1. gwt-maven-example-master
    • pom.xml
    • 服务器
      • pom.xml
      • ...
    • 共享
      • pom.xml
      • ...
    • 网络
      • pom.xml
      • ...

父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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>de.hpfsc</groupId>
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0-SNAPSHOT</version>

    <modules>
        <module>server</module>
        <module>shared</module>
        <module>web</module>
    </modules>

    <properties>
        <gwtVersion>2.5.0</gwtVersion>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <tomcat.webport>8082</tomcat.webport>
        <tomcat.ajpport>8182</tomcat.ajpport>
        <tomcat.context>/parent</tomcat.context>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.5.0-rc2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <path>${tomcat.context}</path>
                    <port>${tomcat.webport}</port>
                    <ajpPort>${tomcat.ajpport}</ajpPort>
                    <systemProperties>
                        <JAVA_OPTS>-XX:MaxPermSize=256m</JAVA_OPTS>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

当我尝试将包含此 pom 的文件夹导入 eclipse 时,它​​允许我选择子文件夹而不是父文件夹本身。

为什么不能导入父pom? 我尝试创建一个父文件夹,将 pom.xml 放入其中并使用 ../server 引用其他模块,但它不起作用。 我试图从父pom中删除与tomcat配置相关的代码,它也不起作用。

谢谢

【问题讨论】:

  • 您如何尝试导入项目?你有安装m2e插件吗?你用什么eclipse版本? (而且,欢迎!)

标签: java eclipse maven gwt pom.xml


【解决方案1】:

您需要安装 m2e 插件(根据 eclipse 的版本,您可能已经安装了该插件)。我猜目前您正在执行“导入”然后是“将现有项目导入工作区”,但您需要选择“现有 Maven 项目”。这将允许您选择父 pom 以及子模块。

【讨论】:

  • 您好,感谢您的回答。 M2e 已安装,我正在导入现有的 Maven 项目。问题是 server/pom.xml shared/pom.xml 和 web/pom.xml 可以选择,但是 /pom.xml 被禁用并且无法选择
  • 当您单击禁用的父 pom 时,eclipse 通常会显示一条消息,告诉您为什么禁用它,例如“项目已导入工作区”。此外,我刚刚尝试过它,它在 Eclipse Indigo SR2 和 m2e 1.0.200 中对我来说很好。尝试在父节点上运行 mvn clean install 以检查整个项目是否正确构建。
猜你喜欢
  • 2023-03-25
  • 2016-06-12
  • 2014-03-28
  • 2018-02-11
  • 1970-01-01
  • 2015-10-06
  • 2017-03-28
  • 2018-10-15
  • 2013-01-19
相关资源
最近更新 更多