问题描述
在我创建一个带有websockets且没有maven的简单动态Web项目之前,它工作正常。现在我尝试使用maven。但是当我用 mvn编译jetty编译我的项目时:运行
它不用构建javax.servlet.UnavailableException:Servlet类com.example .testbattle.ServerSide不是javax.servlet.Servlet
异常。它需要实现Servlet接口。为什么我不需要简单的动态Web项目。我怎么能避免这个问题呢?
Before I made a simple dynamic web project with websockets and without maven, it works fine. Now I try to use maven. But when I'm compiling my project with mvn compile jetty:run
it doesn't build with javax.servlet.UnavailableException: Servlet class com.example.testbattle.ServerSide is not a javax.servlet.Servlet
exception. It requires to implement Servlet interface. Why didn't I need it with simple dynamic web project. How could I avoid this problem?
UPDATE :我发现问题是错误的web.xml现在我无法启动服务器端。我应该把什么放进web.xml?
UPDATE: I have found out the problem it was wrong web.xml Now I can't launch serverside. What should I put into web.xml?
推荐答案
这样的错误报告你试图注册通过非servlet 类作为servlet的一个,这里的意思是显而易见的 com.example.testbattle.ServerSide
没有实现 javax.servlet.Servlet
或扩展它的子类。
Such an error reports that you are trying to register pass an non servlet class as a servlet one, meaning here that obviousely com.example.testbattle.ServerSide
does not implement javax.servlet.Servlet
or extend a subclass of it.
如果 com.example.testbattle.ServerSide
是打算成为你的Servlet应用程序入口点,然后继续实现所提到的接口及其所有派生方法( onService
...)。
If com.example.testbattle.ServerSide
is intended to be your Servlet application entry point then go ahead an implement the mentioned interface and all its derived methods (onService
...).
这篇关于Maven不编译webapp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!