当前位置: 首页 > 知识库问答 >
问题:

GWT超级开发模式不编译最新的源代码

贺华容
2023-03-14

我有一个使用GWT2.7.0的GWT项目,并且正在使用Maven。该应用程序正在正确编译和运行,然而,我正在努力使GWT的超级开发模式正常工作。当我用

mvn gwt:run-codeserver

超级开发模式正确启动,编译,最新的更改显示在浏览器中。但是,当我按compile bookmarklet重新编译GWT代码时,重新编译正确完成,浏览器刷新,但不包括我对客户机/GWT java文件所做的任何后续更改。

当启动GWT Super Dev模式时,它似乎将源文件(.java文件)从src/main/java复制到Maven的构建文件夹(target),并且它似乎是从目标文件夹中的源文件编译,而不是从src/main/java中的源文件编译。我已经测试了这一点,方法是手动将一个我修改过的java文件从src/main/java复制到目标文件夹中,然后点击compile bookmarklet。当我这样做时,重新编译会像以前一样成功,并显示最新的更改。

我假设我错过了将src/main/java复制到目标文件夹的配置,或者我错误地配置了Super Dev模式,在目标文件夹应该从src/main java源代码编译时从目标文件夹编译

任何帮助,以了解它应该如何运作和解决这一点,将不胜感激。

my pom.xml的相关部分:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><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>
...
<packaging>war</packaging>
<version>0.1.0.BUILD-SNAPSHOT</version>
...

<properties>
    <java.version>7</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <slf4j.version>1.7.12</slf4j.version>
    <spring.version>4.2.2.RELEASE</spring.version>
    <spring-security.version>3.2.8.RELEASE</spring-security.version>
    <spring-data.version>1.9.0.RELEASE</spring-data.version>
    <spring.integration.version>4.2.0.RELEASE</spring.integration.version>
    <hazelcast.version>3.6.4</hazelcast.version>
    <aspectj.version>1.8.5</aspectj.version>
    <gwt.version>2.7.0</gwt.version>
    <cucumber.version>1.2.4</cucumber.version>
    <togglz.version>2.1.0.Final</togglz.version>
    <apache.poi.version>3.16</apache.poi.version>
    <skipTests>true</skipTests>
</properties>

<repositories>
    <repository>
        <id>spring-maven-release</id>
        <name>Spring Maven Release Repository</name>
        <url>http://maven.springframework.org/release</url>
    </repository>
    <repository>
        <id>spring-maven-milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://maven.springframework.org/milestone</url>
    </repository>
    <repository>
        <id>maven.springframework.org.external</id>
        <url>http://maven.springframework.org/external</url>
        <name>SpringSource Maven Repository - External Releases</name>
    </repository>
    <repository>
        <id>ailis-releases</id>
        <name>Ailis Maven Releases</name>
        <url>http://nexus.ailis.de/content/groups/public/</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-maven-release</id>
        <name>Spring Maven Release Repository</name>
        <url>http://maven.springframework.org/release</url>
    </pluginRepository>
    <pluginRepository>
        <id>spring-maven-milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://maven.springframework.org/milestone</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>

    <!-- Spring dependencies -->
    ...

    <!-- General dependencies -->

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>javax.el-api</artifactId>
        <version>2.2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- GWT dependencies -->

    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwt.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwt.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt.inject</groupId>
        <artifactId>gin</artifactId>
        <version>2.1.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt.eventbinder</groupId>
        <artifactId>eventbinder</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.gwtupload</groupId>
        <artifactId>gwtupload</artifactId>
        <version>1.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt.google-apis</groupId>
        <artifactId>gwt-visualization</artifactId>
        <version>1.1.2</version>
    </dependency>

</dependencies>

<build>
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>

    <plugins>
        <!-- Clean -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>src/main/webapp/app</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

        <!-- War -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
        </plugin>

        <!-- Compiler -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>

        <!-- Aspectj -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.4</version>
            <!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 issue  -->
            <dependencies>
                <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) -->
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <!--
                  Aspects in src/main/java and src/main/aspects are added
                  as default in the compile goal.
                  Aspects in src/getAllClients/java and src/getAllClients/aspects are added
                  as default in the getAllClients-compile goal.
                  Aspects in src/main/java are added in the getAllClients-compile
                  goal if weaveWithAspectsInMainSourceFolder is set to true
                -->
                <weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>
            </configuration>
        </plugin>

        <!-- Resources -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.outputDirectory}/za/co/shared/domain/i18n
                        </outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/java/za/co/shared/domain/i18n</directory>
                                <includes>
                                    <include>**/*.properties</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <!-- Assembly -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

        <!-- Deploy -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.7</version>
        </plugin>

        <!-- Tomcat -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>8080</port>
                <path>/app</path>
            </configuration>
        </plugin>

        <!-- GWT -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>${gwt.version}</version>
            <configuration>
                <logLevel>INFO</logLevel>
                <style>PRETTY</style>
                <runTarget>/app</runTarget>
                <modules>
                    <module>${project.groupId}.app</module>
                </modules>
                <extraJvmArgs>-XX:MaxPermSize=2048m -Xmx2048m</extraJvmArgs>
                <localWorkers>1</localWorkers>
                <inplace>true</inplace>
                <noServer>true</noServer>
                <draftCompile>false</draftCompile>
                <compileReport>false</compileReport>
                <compilerMetrics>false</compilerMetrics>
                <i18nConstantsBundle>za.co.shared.domain.i18n.GlobalConstants</i18nConstantsBundle>
            </configuration>
            <executions>
                <execution>
                    <id>gwt-compile-on-package</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>gwt-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
                <execution>
                    <id>gwt-clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-dev</artifactId>
                    <version>${gwt.version}</version>
                </dependency>
                <dependency>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-user</artifactId>
                    <version>${gwt.version}</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins>
</build>

共有1个答案

西门经国
2023-03-14

https://tbroyer.github.io/gwt-maven-plugin/codeserver.html

从GWT2.7开始,应该设置launcherdir属性以在重新加载时获得重新编译。该属性应该指向一个文件夹,您的web服务器/servlet容器将在该文件夹中查找web资源,以便由CodeSever生成的*.nocache.js文件可以由您的web浏览器加载。

 类似资料:
  • 我对GWT是新手。我不知道如何启动超级开发模式。我需要一步一步的详细解释。 但我不明白这一点。

  • GWT-2.5-super-dev-mode 引入超级开发模式 GWT的超级开发模式是如何工作的? 然而,我在尝试打开超级开发模式的步骤中被卡住了: 调试文件中的js代码时,脚本在第324行中断: 一旦函数被调用,就会运行更多的模糊函数,调试器就会返回。 我知道这仍然是实验性的,但你知道我可能做错了什么吗? PS:我使用的是gwt2.5、gwt-maven-plugin2.5和Chrome 23.

  • 在GWT 2.5之前,默认情况下所有css类都被混淆了,但在GWT 2.7中,在超级开发模式下运行时,它会在类名中附加完整的包。我在下面尝试过,但它不起作用。 我并没有混淆css样式,而是像com谷歌gwt用户cellview客户端CellTable样式cellTableCell一样打印名称。

  • 我试图通过mvn GWT:run-codeserver用maven在超级开发模式下运行GWT应用程序。这个插件给了我一个localhost页面,作为建议,我将上,然后访问页面中提供的链接。 然后我单击书签栏上上的

  • 我已经安装了2.8.1版本的GWT SDK。我可以用Jersy在GWT中运行应用程序。但是,当我尝试在GWT开发模式(超级)下运行应用程序时,会生成类似http://127.0.0.1:9876的URL。当我在浏览器中放置此URL时,没有加载预期的UI页面。我得到的页面就像, 我甚至在浏览器级别添加了GWT扩展,并尝试了相同的方法。但是,还是没有运气。 我没有尝试使用eclipse下载的GWT S