我无法弄清楚为什么我在下面收到此错误我已经包含了所有适当的jar(据我所知,我已经包含了eclipses .classpath文件。)所有的classpath条目都解决得很好。我错过了什么?
无法解析javax.servlet.ServletContextListener类型。它是从“extends GuiceServletContextListener”行中的必需.class文件间接引用的
-
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
public class ServletConfig extends GuiceServletContextListener {
@Override
protected Injector getInjector() {
return Guice.createInjector(new ServletModule(){
@Override
protected void configureServlets() {
// TODO: add necessary code to bind
}
});
}
}
.Classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_21">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="oracle.eclipse.tools.glassfish.lib.system">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="guice-3.0/aopalliance.jar"/>
<classpathentry kind="lib" path="guice-3.0/guice-3.0.jar"/>
<classpathentry kind="lib" path="guice-3.0/guice-servlet-3.0.jar"/>
<classpathentry kind="lib" path="guice-3.0/javax.inject.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
答案 0 :(得分:0)
Eclipse需要连接到glassfish服务器才能使其正常工作。
当SO让我时,会将此标记为正确。