我得到了2个课程P
.接口类A
及其实现类B
.在带有类的文件中,B
我收到以下错误:The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
.
我正在使用Eclipse Helios和
$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)
Run Code Online (Sandbox Code Playgroud)
删除和添加JRE的标准解决方案不起作用.我该如何解决?
编辑:
代码:
类A
:
package com.jax;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public interface WebServiceInter {
@WebMethod
String sayHello();
}
Run Code Online (Sandbox Code Playgroud)
课程B
:
package com.jax; // **Error is here**
import javax.jws.WebService;
@WebService(endpointInterface = "com.jax.WebServiceInter")
public class WebServiceImpl implements WebServiceInter{
@Override
public String sayHello(){
return "Hello!";
}
}
Run Code Online (Sandbox Code Playgroud)
项目结构:ProjectName - > Java Resources - > com.jax - > Class A
,ClassB
mkr*_*hin 82
Java 8支持接口中的默认方法.在JDK 8中,许多旧接口现在都有新的默认方法.例如,现在在CharSequence中我们有chars和codePoints方法.
如果项目的源级别低于1.8,则编译器不允许您在接口中使用默认方法.因此它无法编译直接间接依赖于此接口的类.
如果我的问题正确,那么你有两个解决方案.第一种解决方案是回滚到JDK 7,然后您将使用旧的CharSequence接口而不使用默认方法.第二种解决方案是将项目的源级别设置为1.8,然后编译器不会抱怨接口中的默认方法.
归档时间: |
|
查看次数: |
153052 次 |
最近记录: |