GWT 2.7.0 项目不使用 maven gwt:compile 编译:注释错误

GWT 2.7.0 project doesn't compile with maven gwt:compile: Annotation errors

我创建了一个 Maven GWT 项目,运行在 Eclipse 中很好。但是,当我在命令行上调用 mvn gwt:compile 时,出现以下错误:

[INFO] Scanning for projects...

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building de.GWT_App 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gwt-maven-plugin:2.7.0:compile (default-cli) @ GWT_App ---
[INFO] Compiling module de.GWT_App
[INFO]    Ignored 1 unit with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    Resolving de.client.AppPlaceHistoryMapper
[INFO]       Found type 'de.client.AppPlaceHistoryMapper'
[INFO]          Resolving annotation for com.google.gwt.place.shared.WithTokenizers
[INFO]             [WARN] Annotation error: cannot resolve de.client.presenters.login.LoginTokenizer
[INFO]             [ERROR] Annotation error: expected class java.lang.Class, got null
[INFO]    Resolving de.client.proxy.UserProxy
[INFO]       Found type 'de.client.proxy.UserProxy'
[INFO]          Resolving annotation for com.google.web.bindery.requestfactory.shared.ProxyFor
[INFO]             [WARN] Annotation error: cannot resolve de.client.model.User
[INFO]             [WARN] Annotation error: cannot resolve de.client.locator.UserLocator
[INFO]    Resolving de.client.proxy.VeranstaltungProxy
[INFO]       Found type 'de.client.proxy.VeranstaltungProxy'
[INFO]          Resolving annotation for com.google.web.bindery.requestfactory.shared.ProxyFor
[INFO]             [WARN] Annotation error: cannot resolve de.client.model.Veranstaltung
[INFO]    Resolving de.client.requestfactory.UserRequestFactory.UserRequestContext
[INFO]       Found type 'de.client.requestfactory.UserRequestFactory.UserRequestContext'
[INFO]          Resolving annotation for com.google.web.bindery.requestfactory.shared.Service
[INFO]             [WARN] Annotation error: cannot resolve de.client.dao.UserDAOImpl
[INFO]             [WARN] Annotation error: cannot resolve de.client.locator.DAOLocator
[INFO]    Computing all possible rebind results for 'de.client.AppPlaceHistoryMapper'
[INFO]       Rebinding de.client.AppPlaceHistoryMapper
[INFO]          Invoking generator com.google.gwt.place.rebind.PlaceHistoryMapperGenerator
[INFO]             [ERROR] Generator 'com.google.gwt.place.rebind.PlaceHistoryMapperGenerator' threw an exception while rebinding 'de.client.AppPlaceHistoryMapper'
[INFO] java.lang.NullPointerException
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryGeneratorContext.getWithTokenizerEntries(PlaceHistoryGeneratorContext.java:272)
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryGeneratorContext.initTokenizersWithoutGetters(PlaceHistoryGeneratorContext.java:316)
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryGeneratorContext.ensureInitialized(PlaceHistoryGeneratorContext.java:186)
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryGeneratorContext.getPlaceTypes(PlaceHistoryGeneratorContext.java:146)
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryMapperGenerator.writeGetPrefixAndToken(PlaceHistoryMapperGenerator.java:108)
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryMapperGenerator.generateOnce(PlaceHistoryMapperGenerator.java:93)
[INFO]  at com.google.gwt.place.rebind.PlaceHistoryMapperGenerator.generate(PlaceHistoryMapperGenerator.java:56)
[INFO]  at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
[INFO]  at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:760)
[INFO]  at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:160)
[INFO]  at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79)
[INFO]  at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276)
[INFO]  at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:265)
[INFO]  at com.google.gwt.dev.DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(DistillerRebindPermutationOracle.java:87)
[INFO]  at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createStaticRebindExpression(UnifyAst.java:485)
[INFO]  at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createRebindExpression(UnifyAst.java:443)
[INFO]  at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleMagicMethodCall(UnifyAst.java:576)
[INFO]  at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.endVisit(UnifyAst.java:306)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:248)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:128)
[INFO]  at com.google.gwt.dev.jjs.ast.JCastOperation.traverse(JCastOperation.java:67)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:128)
[INFO]  at com.google.gwt.dev.jjs.ast.JDeclarationStatement.traverse(JDeclarationStatement.java:49)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:95)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:351)
[INFO]  at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:149)
[INFO]  at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:145)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:600)
[INFO]  at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:569)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO]  at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO]  at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:1505)
[INFO]  at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:870)
[INFO]  at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.unifyJavaAst(JavaToJavaScriptCompiler.java:1305)
[INFO]  at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.constructJavaAst(JavaToJavaScriptCompiler.java:1038)
[INFO]  at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.precompile(JavaToJavaScriptCompiler.java:954)
[INFO]  at com.google.gwt.dev.jjs.MonolithicJavaToJavaScriptCompiler.precompile(MonolithicJavaToJavaScriptCompiler.java:303)
[INFO]  at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:38)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:286)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:206)
[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:158)
[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:120)
[INFO]  at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
[INFO]  at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
[INFO]  at com.google.gwt.dev.Compiler.main(Compiler.java:127)
[INFO]    [ERROR] Errors in 'de/hs_karlsruhe/client/GWT_App.java'
[INFO]       [ERROR] Line 42: Failed to resolve 'de.client.AppPlaceHistoryMapper' via deferred binding
[INFO]    [WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
[INFO]       [WARN] de.client.AppPlaceHistoryMapperImpl
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.497 s
[INFO] Finished at: 2016-01-20T13:20:11+01:00
[INFO] Final Memory: 16M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.7.0:compile (default-cli) on project GWT_App: Command [[
[ERROR] C:\Java\JDK\jre\bin\java -Xmx512m -classpath D:\Workspace\GWT_App\target\classes;D:\Workspace\GWT_App\src\main\java;D:\Maven_Local_Repository\com\google\gwt\gwt-user.7.0
\gwt-user-2.7.0.jar;D:\Maven_Local_Repository\javax\validation\validation-api.0.0.GA\validation-api-1.0.0.GA-sources.jar;D:\Maven_Local_Repository\com\google\gwt\gwt-dev.7.0\gwt-dev-2.7.0.jar
;D:\Maven_Local_Repository\org\ow2\asm\asm.0.3\asm-5.0.3.jar;D:\Maven_Local_Repository\org\ow2\asm\asm-util.0.3\asm-util-5.0.3.jar;D:\Maven_Local_Repository\org\ow2\asm\asm-tree.0.3\asm-tre
e-5.0.3.jar;D:\Maven_Local_Repository\org\ow2\asm\asm-commons.0.3\asm-commons-5.0.3.jar;D:\Maven_Local_Repository\com\google\gwt\gwt-codeserver.7.0\gwt-codeserver-2.7.0.jar;D:\Maven_Local_Rep
ository\com\googlecode\mgwt\mgwt.0.0\mgwt-2.0.0.jar;D:\Maven_Local_Repository\org\json\json151123\json-20151123.jar;D:\Maven_Local_Repository\javax\validation\validation-api.0.0.GA\validat
ion-api-1.0.0.GA.jar;D:\Maven_Local_Repository\org\hibernate\hibernate-validator.2.2.Final\hibernate-validator-5.2.2.Final.jar;D:\Maven_Local_Repository\org\jboss\logging\jboss-logging.2.1.Fi
nal\jboss-logging-3.2.1.Final.jar;D:\Maven_Local_Repository\com\fasterxml\classmate.1.0\classmate-1.1.0.jar;D:\Maven_Local_Repository\org\hibernate\hibernate-annotations.5.6-Final\hibernate-a
nnotations-3.5.6-Final.jar;D:\Maven_Local_Repository\org\hibernate\hibernate-core.5.6-Final\hibernate-core-3.5.6-Final.jar;D:\Maven_Local_Repository\antlr\antlr.7.6\antlr-2.7.6.jar;D:\Maven_L
ocal_Repository\commons-collections\commons-collections.1\commons-collections-3.1.jar;D:\Maven_Local_Repository\dom4j\dom4j.6.1\dom4j-1.6.1.jar;D:\Maven_Local_Repository\xml-apis\xml-apis.0
.b2\xml-apis-1.0.b2.jar;D:\Maven_Local_Repository\javax\transaction\jta.1\jta-1.1.jar;D:\Maven_Local_Repository\org\hibernate\hibernate-commons-annotations.2.0.Final\hibernate-commons-annotat
ions-3.2.0.Final.jar;D:\Maven_Local_Repository\org\hibernate\javax\persistence\hibernate-jpa-2.0-api.0.0.Final\hibernate-jpa-2.0-api-1.0.0.Final.jar;D:\Maven_Local_Repository\org\slf4j\slf4j-ap
i.5.8\slf4j-api-1.5.8.jar;D:\Maven_Local_Repository\com\google\gwt\inject\gin.1.2\gin-2.1.2.jar;D:\Maven_Local_Repository\com\google\inject\guice.0\guice-3.0.jar;D:\Maven_Local_Repository\j
avax\inject\javax.inject\javax.inject-1.jar;D:\Maven_Local_Repository\aopalliance\aopalliance.0\aopalliance-1.0.jar;D:\Maven_Local_Repository\com\google\inject\extensions\guice-assistedinject
.0\guice-assistedinject-3.0.jar;D:\Maven_Local_Repository\org\gwtbootstrap3\gwtbootstrap3[=11=].9.2\gwtbootstrap3-0.9.2.jar;D:\Maven_Local_Repository\com\google\gwt\gwt-user.7.0\gwt-user-2.7.0.ja
r;D:\Maven_Local_Repository\javax\validation\validation-api.0.0.GA\validation-api-1.0.0.GA.jar;D:\Maven_Local_Repository\javax\validation\validation-api.0.0.GA\validation-api-1.0.0.GA-sources
.jar;D:\Maven_Local_Repository\com\google\gwt\gwt-dev.7.0\gwt-dev-2.7.0.jar;D:\Maven_Local_Repository\org\ow2\asm\asm.0.3\asm-5.0.3.jar;D:\Maven_Local_Repository\org\ow2\asm\asm-util.0.3\as
m-util-5.0.3.jar;D:\Maven_Local_Repository\org\ow2\asm\asm-tree.0.3\asm-tree-5.0.3.jar;D:\Maven_Local_Repository\org\ow2\asm\asm-commons.0.3\asm-commons-5.0.3.jar com.google.gwt.dev.Compiler
-logLevel INFO -style OBF -war D:\Workspace\GWT_App\target\GWT_App-1.0-SNAPSHOT -localWorkers 8 -compileReport -XfragmentCount -1 -sourceLevel 1.7 -extra D:\Workspace\GWT_App\targ
et\extra -gen D:\Workspace\GWT_App\target\.generated de.GWT_App
[ERROR] ]] failed with status 1
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我已经阅读了关于此的其他帖子以及我的理解方式,它与 GWT 编译器找不到 类 有关。但是,我不明白所提供的解决方案。

有人说你需要用 javac 编译 类 并将它们添加到类路径中。我如何在 Eclipse 中执行此操作?

其他人说我需要将输出目录从 target/classes 更改为 WEB-INF。我试过了,但是每次我 运行 项目和 web.xml 文件被删除时,WEB-INF 目录都会被清空。这肯定不是正确的方法。

我该如何处理?

您需要先调用 mvn process-classes(如果您在 process-classes 阶段没有任何东西,则需要调用 mvn compile),然后才能调用 mvn gwt:compile.

其实我想问的是你为什么要从command-line打电话给gwt:compile。大多数时候,您真正想要的实际上是 mvn prepare-package -DskipTestsmvn package -DskipTests.