【问题标题】:GWT 2.7 maven project integration with eclipseGWT 2.7 maven 项目与 eclipse 集成
【发布时间】:2015-08-24 15:57:28
【问题描述】:

我找到了与 maven 一起使用的 GWT 2.7.0 应用程序的良好启动器。 这里是repository

不幸的是所有者/创建者不使用 eclipse,所以他可以帮助我。

我希望这个项目能够与 eclipse 一起工作并很好地集成(如官方 ant 项目-stockwatcher f.e.)。

我的问题是我无法在 eclipse 中以超级开发模式运行这个项目。我唯一的选择是: [ f.e.我可以运行安装女巫将编译项目。 但我没有选择在 SuperDevMode 下运行

第二个问题是我无法在项目上使用鼠标右键将 GWT sdk 添加到应用程序 -> 属性,如您在此处看到的:

我可以在 linux konsole 中使用 maven 运行这个项目,但是我不能通过在 eclipse 中单击来执行此操作。

请帮忙


编辑

从 git 存储库导入后,我在 eclipse 中的项目结构:

这里是主要的 pom.xml:

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

        <defaultGoal>clean install  tomcat7:run-war-only</defaultGoal>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwtVersion}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
            </plugin>

                <!-- IDE -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.7</version>  <!-- Note 2.8 does not work with AspectJ aspect path -->
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <wtpversion>2.0</wtpversion>
                    <additionalBuildcommands>
                        <buildCommand>
                            <name>org.eclipse.jdt.core.javabuilder</name>
                            <arguments>
                            </arguments>
                        </buildCommand>
                        <buildCommand>
                            <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
                            <arguments>
                            </arguments>
                        </buildCommand>
                        <buildCommand>
                            <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
                            <arguments>
                            </arguments>
                        </buildCommand>
                    </additionalBuildcommands>
                    <additionalProjectnatures>
                        <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
                    </additionalProjectnatures>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</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>

【问题讨论】:

    标签: java eclipse maven gwt gwt-super-dev-mode


    【解决方案1】:

    该项目由 3 个子模块组成。将项目导入 Eclipse 时,您的工作区中应该有 4 个项目:parentsharedserverweb

    parent 应该是一个简单的项目(这就是为什么你在Run As… 中没有太多选项的原因),而sharedserverweb 应该是 Java 项目。

    web 项目是 GWT 客户端代码所在的位置(除了 shared),GPE 应自动将其配置为 GWT 项目,GWT SDK 取自 Maven 依赖项(因此您不会有一个 GWT“库”——用 Eclipse 的说法——在你的依赖项中,只有 JRE/JDK 和一个“Maven 依赖项”库)。
    这也是在 web 项目上,您将 Run As…Web Application

    【讨论】:

    • 为什么我的eclipse只生成三个模块?是因为maven配置不好?我应该创建名为 parent 的新子模块(如服务器 f.e.)吗?或者我应该编辑 main pom.xml 以使其工作。我也明白我必须将 gwt sdk 从 main pom.xml 复制到客户端 pom.xml?
    • 我用Eclipse已经有一段时间了,所以可能我记错了,它不会为父模块创建项目;就 Eclipse 而言,它无论如何都没用。不,您不应该修改 POM。
    • 为什么没用?你提出什么想法,为什么?
    • parent 模块不包含代码,只有“配置”;它在 Eclipse 中用处不大(除了触发“从 Maven 更新项目”或“运行方式…→ Maven”)。我目前正在使用 IntelliJ IDEA,但从那以后没有做过任何真正的 GWT 开发。
    猜你喜欢
    • 2012-12-02
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    • 2011-10-15
    • 2013-04-20
    • 2012-10-15
    • 2020-09-08
    相关资源
    最近更新 更多