【发布时间】:2014-02-12 17:34:21
【问题描述】:
我正在使用 Google Gin 在我的 GWT 项目中生成一个事件,如下所示:
package com.lokur.motd.client.events;
import com.gwtplatform.dispatch.annotation.GenEvent;
@GenEvent
public class EditorChange {
}
现在,当我使用“mvn clean install -e”编译我的项目时,它会生成所需的类,即。我项目的目标文件夹中的 EditorChangeEvent.class、EditorChangeEvent$EditorChangeHandler.class、EditorChangeEvent$HasEditorChangeHandlers.class。
但是,当我尝试访问特定生成的类时,例如EditorChangeEvent 在我的项目中,它给了我编译错误消息:
"包 com.lokur.motd.client.events.EditorChangeEvent 不存在”
...
我不明白这种行为。我们是否需要在类路径或 pom.xml 中的某处显式添加 Maven 的“目标”文件夹或其他原因导致此问题?
这里是来自 maven pom.xml 的插件:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.plugin.version}</version>
<configuration>
<runTarget>myMessage/myMessage.html</runTarget>
<disableCastChecking>true</disableCastChecking>
<disableClassMetadata>true</disableClassMetadata>
<!-- <logLevel>INFO" -bindAddress 0.0.0.0 -logLevel "INFO</logLevel> -->
<logLevel>ERROR</logLevel>
<style>OBF</style>
<!-- OBF, PRETTY, DETAILED -->
<noServer>false</noServer>
<additionalPageParameters>log_level=OFF</additionalPageParameters>
<extraJvmArgs>-Xmx512m -Ddev.mode=true -DuseCache=false</extraJvmArgs>
<extraTestArgs>-Xmx512m -Ddev.mode=true</extraTestArgs>
<gwtVersion>${gwtVersion}</gwtVersion>
<testFilter>*</testFilter>
<hostedWebapp>
${project.build.directory}/${project.build.finalName}
</hostedWebapp>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>Unzip usp Config & Env Modules</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.dig.configs</groupId>
<artifactId>common-configs</artifactId>
<version>${commonConfigs.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${basedir}/target/tmp</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>${pom.groupId}</groupId>
<artifactId>usp-env</artifactId>
<version>${pom.version}</version>
<type>zip</type>
<outputDirectory>${basedir}/target/tmp</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>Copy Config, Env Modules</id>
<phase>generate-resources</phase>
<configuration>
<tasks>
<copy todir="${basedir}/target/myMessage/WEB-INF/classes/config" overwrite="true" verbose="true" failonerror="true">
<fileset dir="${basedir}/target/tmp/config">
<include name="**" />
</fileset>
<fileset dir="${basedir}/target/tmp/env">
<include name="**" />
</fileset>
</copy>
<copy todir="${basedir}/target/myMessage/WEB-INF/classes/config" overwrite="true" verbose="true" failonerror="true">
<fileset dir="../config/test" includes="**" />
</copy>
<copy file="${basedir}/../config/usp-app-config.xml" todir="${basedir}/target/myMessage/WEB-INF/classes/config" />
<copy file="${basedir}/../usp-env/src/test/env/usp-app-config.properties" todir="${basedir}/target/myMessage/WEB-INF/classes" />
<copy file="${basedir}/../usp-env/src/test/env/app-config.properties" todir="${basedir}/target/myMessage/WEB-INF/classes" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
【问题讨论】:
-
“尝试访问”是什么意思?你是说你的IDE吗?
-
@Nick Holt:是的。在同一个项目中访问其他类文件以创建它的实例或用于其他目的..
-
你使用什么 Maven 插件来生成类?
-
@Nick Holt:我不是 Maven 专家。有没有这样的插件来生成类?你能举个例子吗...
-
您说您的 Maven 构建正在生成
EditorChangeEvent等 - 默认情况下不会这样做,通常您需要添加一个插件 - 什么插件已添加到您的 pom.xml ?
标签: java gwt intellij-idea maven-2 gwt-gin