GWT使用热插拔代理和SDM

时间:2017-04-23 02:19:52

标签: java maven intellij-idea gwt hotswap

我正在Intellij中构建一个示例GWT项目。问题是我的服务模块中的代码更改未反映在webapp中。

以下是我项目的结构:

父POM:

<modules>
    <module>gwt-widgets</module>
    <module>gwt-core</module>
    <module>gwt-services</module>
    <module>gwt-rpc</module>
</modules>
<packaging>pom</packaging>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

gwt-core:这是一个网络应用程序:

<packaging>war</packaging>
<artifactId>gwt-core</artifactId>
<dependencies>
    <dependency>
        <groupId>com.tuannguyen.gwt</groupId>
        <artifactId>gwt-widgets</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.tuannguyen.gwt</groupId>
        <artifactId>gwt-widgets</artifactId>
        <version>1.0-SNAPSHOT</version>
        <classifier>sources</classifier>
        <scope>provided</scope><!-- use for compilation only -->
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
    </dependency>
    <dependency>
        <groupId>com.tuannguyen.gwt</groupId>
        <artifactId>gwt-services</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.tuannguyen.gwt</groupId>
        <artifactId>gwt-rpc</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.tuannguyen.gwt</groupId>
        <artifactId>gwt-rpc</artifactId>
        <version>1.0-SNAPSHOT</version>
        <classifier>sources</classifier>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>2.6.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>generateAsync</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <modules>
                    <module>com.tuannguyen.widgets.Widgets</module>
                    <module>com.tuannguyen.example.Examples</module>
                    <module>com.tuannguyen.example.Services</module>
                </modules>
                <runTarget>gwtia-ch04-widgets.html</runTarget>
                <compileSourcesArtifacts>
                    <compileSourcesArtifact>com.tuannguyen.gwt:gwt-widgets</compileSourcesArtifact>
                    <compileSourcesArtifact>com.tuannguyen.gwt:gwt-services</compileSourcesArtifact>
                    <compileSourcesArtifact>com.tuannguyen.gwt:gwt-rpc</compileSourcesArtifact>
                </compileSourcesArtifacts>

            </configuration>

        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <archiveClasses>true</archiveClasses>
                <warSourceExcludes>WEB-INF/classes/**</warSourceExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.3.8.RC0</version>
        </plugin>
    </plugins>
</build>

Examples.gwt.xml:gwt-core中的模块

<module rename-to="Examples">
<!-- inherit the standard User module as all GWT applications must -->
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.tuannguyen.widgets.Widgets'/>
<inherits name='com.tuannguyen.example.Services'/>

<!-- Use the standard theme for widgets -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>

<!-- note the entry point for the application -->
<entry-point class='com.tuannguyen.example.client.Examples'/>

<!-- Indicate where the code that should be translated to Javascript can be found.
     By default this is in the client package, but we indicate that explicitly in
     this example, just to introduce the tag. -->
<source path='client'/>
<add-linker name="xsiframe"/>
<set-configuration-property name="devModeRedirectEnabled" value="true" />

GWT服务:

<dependencies>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.tuannguyen.gwt</groupId>
        <artifactId>gwt-rpc</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

gwt-widgets,它是gwt-core中使用的gwt模块:

dependencies>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
        </plugin>
    </plugins>
</build>

一些问题:

  1. 我使用mvn clean install,mvn gwt:run-codeserver和mvn jetty:run-explosion运行gwt-core中的超级开发模式,成功构建了web应用程序。但是,当我使用'Dev Mode On'书签重新编译gwt-core时,gwt-widgets的更改不会反映出来。如果我使用Intellij Run Configuration运行Web应用程序,那么它可以正常工作。
  2. 我在gwt-core的src / main / resources文件夹中创建了以下hotswap-agent.properties文件。但是,当我重新编译类fileg时,Web应用程序无法获取gwt-services的更改。我的属性文件的内容是:extraClasspath = gwt-services / target / classes
  3. 这些问题有解决办法吗?

0 个答案:

没有答案