【发布时间】:2009-11-11 09:08:40
【问题描述】:
我面临一个问题。我有一个名为“ReportingService”的类,它应该是单例的,并且正在扩展“CommonService”。
package MyApp.Services.ReportingService;
public class ReportingService extends CommonService {
private static ReportingService instance = null;
public static ReportingService getInstance() {
if (instance == null) {
instance = new ReportingService();
}
return instance;
}
}
并在我正在使用的其他类中访问该类
package MyApp.Services.WebReportingService;
@WebMethod(operationName = "registerUDP")
public boolean registerUDP(
@WebParam(name = "Friendly Name") String friendlyName,
@WebParam(name = "Username") String username,
@WebParam(name = "Password") String password,
@WebParam(name = "Communication Protocol") CommunicationProtocol communicationProtocol,
@WebParam(name = "IP Address") String ipAddress,
@WebParam(name = "Port") int port) {
Consumer client = new Consumer(friendlyName, username, password, communicationProtocol, ipAddress, port);
ReportingService rs = ReportingService.
return true;
}
在“ReportingService rs = ReportingService”中。它没有显示 ReportingService 类的 getInstance() 方法。我还导入了正确的包。
注意:两个类位于不同的包中。
【问题讨论】:
-
您导入了 ReportingService 吗?
-
但是即使在IDE中也不显示方法,可以手动添加并编译代码吗?
-
看起来您只是在 IDE 中遇到了自动完成问题...尝试键入 ReportingService.getInstance() 并查看您是否有编译错误
-
那是 IDE 中的确切代码吗?