祝大家有美好的一天!我正在尝试根据Google的“具有活动和地点的GWT开发”的教程示例创建一个项目。我已经创建了多个地点,并且在每个地点内都设有Tokenizer类。当我尝试编译项目时,出现以下错误:

Found type 'com.calendarmvp.client.mvp.AppPlaceHistoryMapper'
     [ERROR] Annotation error: cannot resolve  com.calendarmvp.client.place.GreetingsPlace$Tokenizer
    java.lang.ClassNotFoundException: com.calendarmvp.client.place.GreetingsPlace$Tokenizer
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotationValue(TypeOracleMediator.java:750)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotationValue(TypeOracleMediator.java:689)
at com.google.gwt.dev.javac.TypeOracleMediator.createAnnotation(TypeOracleMediator.java:498)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotation(TypeOracleMediator.java:648)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotations(TypeOracleMediator.java:663)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveClass(TypeOracleMediator.java:809)
at com.google.gwt.dev.javac.TypeOracleMediator.addNewTypes(TypeOracleMediator.java:439)
at com.google.gwt.dev.javac.TypeOracleMediatorFromSource.addNewUnits(TypeOracleMediatorFromSource.java:52)
at com.google.gwt.dev.javac.CompilationState.assimilateUnits(CompilationState.java:164)
at com.google.gwt.dev.javac.CompilationState.<init>(CompilationState.java:82)
at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:450)
at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:252)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
at com.google.gwt.dev.Compiler.run(Compiler.java:232)
at com.google.gwt.dev.Compiler.run(Compiler.java:198)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
at com.google.gwt.dev.Compiler.main(Compiler.java:177)
   [ERROR] Annotation error: expected class java.lang.Class, got null


我的GreetingsPlace类是这样的:

public class GreetingsPlace extends Place {
  private String GreetingsPlaceName;

  public GreetingsPlace(String place) {
    this.GreetingsPlaceName = place;
  }

  public String getGreetingsPlaceName() {
    return GreetingsPlaceName;
  }

  public static class Tokenizer implements PlaceTokenizer<GreetingsPlace> {

    @Override
    public String getToken(GreetingsPlace place) {
      return place.getGreetingsPlaceName();
    }

    @Override
    public GreetingsPlace getPlace(String token) {
      return new GreetingsPlace(token);
    }
  }
}


AppPlaceHistoryMapper是这样的:

@WithTokenizers({
    HelloPlace.Tokenizer.class,
    GoodbyePlace.Tokenizer.class,
    GreetingsPlace.Tokenizer.class,
    ManagerPlace.Tokenizer.class,
    UserPlace.Tokenizer.class
    })
public interface AppPlaceHistoryMapper extends PlaceHistoryMapper {
}


也许我想念一些东西...谁能帮助我?提前致谢!

最佳答案

您应该在Eclipse中将GWT项目添加到类路径中
运行configurationi(“用户条目”下的类路径)
单击“添加项目..”按钮,然后检查您的GWT项目。
应用运行配置
并运行

其他设置是

主类:com.google.gwt.dev.codeserver.CodeServer

Arg:za CodeServer klasso
程序参数:-bindAddress 0.0.0.0 com.ajna4taiga.recycling.YourGWTModule
VM参数:-Xmx1024m

类路径还应该具有您的GWT项目的src
类路径
用户条目
前进(按钮)
高级文件夹(添加GWT项目的src目录)
Applay保存运行配置

类路径也应该有
gwt-servercode.jar gwt-dev.jar gwt-user.jar验证-api-1.0.0.GA.jar验证-api-1.0.0.GA-sources.jar mgwt-2.0.0.jar

mgwt,如果您有Daniel Kurka的mgwt项目。如果您只有gwt proje,那么您就没有
需要mgwt-2.0.0.jar

10-05 21:20
查看更多