繁体   English   中英

GWT.create(MyClass.class)给出错误,MyClass必须是一个类

[英]GWT.create(MyClass.class) gives Error that MyClass must be a class

我试图从我的EntryPoint类调用RemoteService。 但是,我在GWT.create()中收到错误消息。 我正在为我的服务传递客户端接口。 我得到的错误是它必须是一堂课。

19: private LoginServiceAsync loginServiceAsync = GWT.create(LoginService.class);

[错误]第19行:重新绑定结果'com.example.client.LoginService'必须是一个类

这是我在客户端文件夹中的LoginService代码:

package com.example.client;

import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("LoginService")
public interface LoginService  {
    boolean signUpUser(String name, String email, String password);
}

谁能告诉我我在做什么错? 提前致谢。

GWT.create(MyClass.class)首先查找替换规则或生成规则。 如果GWT找不到规则,它将执行new MyClass()

因为您没有扩展RemoteService ,所以GWT找不到规则的generate,而是尝试一个new

这就是为什么您会收到此错误。

问题是我的界面没有扩展RemoteService。

package com.example.client;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("LoginService")
public interface LoginService extends RemoteService {
    boolean signUpUser(String name, String email, String password);
}

解决了我的问题,我也不得不在LoginServiceAsync中更改此设置:

void signUpUser(String name, String email, String password,com.google.gwt.user.client.rpc.AsyncCallback<java.lang.Boolean> arg4);

不知道为什么这样做,有人可以解释吗? 谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM