java - GWT 代码服务器使用 Maven 原型(prototype)在新生成的项目中找不到模块

标签 java eclipse maven gwt

我已经使用 GWT 和 eclipse 一段时间了,我想尝试一下 maven 和 GWT 插件(gwt-maven-plugin,enter link description here)。我试图在 eclipse (Luna 4.4) 中使用它,但显然我没有正确地使用它,因为它非常脆弱,以至于当我在pom.xml。所以我决定退后一步,消除 eclipse 的黑魔法,并从命令行从头开始一个新项目。

但是,我似乎无法掌握运行实际应用程序的窍门,因为当我执行代码服务器并导航到该页面时,我看到以下消息:

Can't find any GWT Modules on this page.

显然,代码服务器正在运行,但模块文件似乎尚未托管。据我所知,经过几个小时的自学(并找到 http://blog.ltgt.net/how-does-gwts-super-dev-mode-work/ ),应该有第二个进程实际托管与代码服务器并行的代码。使用 Maven 执行此操作的合适方法是什么?我应该打开第二个终端并运行一个 jetty 或其他与代码服务器并行的东西吗?如果是这样,有人可以提示我如何才能最有效地做到这一点吗?

提前致谢!

这是我创建项目的方式:

mvn archetype:generate \
   -DarchetypeGroupId=org.codehaus.mojo \
   -DarchetypeArtifactId=gwt-maven-plugin \
   -DarchetypeVersion=2.7.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [org.codehaus.mojo:gwt-maven-plugin:2.7.0] found in catalog remote
Define value for property 'groupId': : com.mytest
Define value for property 'artifactId': : gwtmvntest
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  com.mytest: : com.mytest.gwtmvntest
Define value for property 'module': : GwtMvnTest
Confirm properties configuration:
groupId: com.mytest
artifactId: gwtmvntest
version: 1.0-SNAPSHOT
package: com.mytest.gwtmvntest
module: GwtMvnTest
 Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: gwt-maven-plugin:2.7.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.mytest
[INFO] Parameter: artifactId, Value: gwtmvntest
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mytest.gwtmvntest
[INFO] Parameter: packageInPathFormat, Value: com/mytest/gwtmvntest
[INFO] Parameter: package, Value: com.mytest.gwtmvntest
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: module, Value: GwtMvnTest
[INFO] Parameter: groupId, Value: com.mytest
[INFO] Parameter: artifactId, Value: gwtmvntest
[INFO] project created from Archetype in dir: /private/tmp/mvn/gwtmvntest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:12 min
[INFO] Finished at: 2015-01-14T12:59:17+01:00
[INFO] Final Memory: 15M/310M
[INFO] ------------------------------------------------------------------------

下面是我编译项目的方式:

mvn compile gwt:compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GWT Maven Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gwt-maven-plugin:2.7.0:generateAsync (default) @ gwtmvntest ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gwtmvntest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ gwtmvntest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /private/tmp/mvn/gwtmvntest/target/gwtmvntest-1.0-SNAPSHOT/WEB-INF/classes
[INFO]
[INFO] --- gwt-maven-plugin:2.7.0:compile (default-cli) @ gwtmvntest ---
[INFO] Compiling module com.mytest.gwtmvntest.GwtMvnTest
[INFO]    Compiling 5 permutations
[INFO]       Compiling permutation 0...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 4...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 3...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 2...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 1...
[INFO]    Compile of permutations succeeded
[INFO]    Compilation succeeded -- 13.866s
[INFO] Linking into /private/tmp/mvn/gwtmvntest/target/gwtmvntest-1.0-SNAPSHOT/GwtMvnTest
[INFO]    Link succeeded
[INFO]    Linking succeeded -- 0.171s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.228 s
[INFO] Finished at: 2015-01-14T13:07:07+01:00
[INFO] Final Memory: 22M/310M
[INFO] ------------------------------------------------------------------------

这是我运行项目的方式:

mvn gwt:run-codeserver
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GWT Maven Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> gwt-maven-plugin:2.7.0:run-codeserver (default-cli) > process-classes @ gwtmvntest >>>
[INFO]
[INFO] --- gwt-maven-plugin:2.7.0:generateAsync (default) @ gwtmvntest ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gwtmvntest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ gwtmvntest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< gwt-maven-plugin:2.7.0:run-codeserver (default-cli) < process-classes @ gwtmvntest <<<
[INFO]
[INFO] --- gwt-maven-plugin:2.7.0:run-codeserver (default-cli) @ gwtmvntest ---
[INFO] Turning off precompile in incremental mode.
[INFO] Super Dev Mode starting up
[INFO]    workDir: /var/folders/nk/58gyq85x7l3_mzb5rc0gw42w0000gn/T/gwt-codeserver-5859907708379954718.tmp
[INFO]    Loading Java files in com.mytest.gwtmvntest.GwtMvnTest.
[INFO]    Module setup completed in 11742 ms
[ERROR] 2015-01-14 13:14:35.800:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
[ERROR] 2015-01-14 13:14:35.833:INFO:oejs.AbstractConnector:Started SelectChannelConnector@127.0.0.1:9876
[INFO]
[INFO] The code server is ready at http://localhost:9876/

最佳答案

对于 GWT 2.7+,您只需要启动 mvn gwt:run,它将在幕后使用 SuperDevMode,并带有“加载时重新编译”(而不是使用小书签)。
请注意,gwt:run 不会复制您的 src/main/webapp 或您的依赖项,因此您可能必须运行 mvn war:exploded(或mvn package)作为先决条件(每次更改src/main/webapp中的文件或需要刷新依赖项时)

也就是说,除非您的项目真的很简单,否则您应该尽早开始为客户端和服务器代码使用不同的 Maven 模块;这是因为 Maven 坚持不能在同一个 POM 中管理“GWT 客户端类路径”和“服务器端类路径”。
我发布了原型(prototype)来帮助设置一切:https://github.com/tbroyer/gwt-maven-archetypes (不幸的是,我还没有时间将它们更新到 GWT 2.7)
要么,要么使用 Gradle……

关于java - GWT 代码服务器使用 Maven 原型(prototype)在新生成的项目中找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27942953/

相关文章:

java - Spring Boot和Hibernate : for org. springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor

java - Spring MVC 模拟

java - 如何跟踪普通 Spring 微服务应用程序(非 Spring boot)中的请求?

java - Java中右键复制粘贴

java - 如何在 Eclipse 中为可选 Java 异常生成代码

Eclipse Appengine 项目 : "errors exist in required project" but nothing is red on debug or run

java - 我如何报告测试结果并使用 maven/junit/spock 按功能编号对它们进行分组?

java - 将一个字符串分成两部分

java - 使用 java.io.File 在 Eclipse 中创建目录

maven - 添加依赖项时 : CDI deployment failure, 使用限定符 @Default 的类型 Set<Service> 的不满足依赖项