解决报错:The import javax.servlet.annotation cannot be resolved

maven项目,引入javax.servlet.annotation.WebServlet的jar包,使用@WebServlet注解来实现对传统web.xml中servlet和url的映射html

报错:The import javax.servlet.annotation cannot be resolvedjava

状况说明:web

  maven项目相关jar包正常引入,且maven能够正常的install,且使用maven启动项目(tomcat7:run)正常,可是就是报错,看着很烦api

 <dependency>
     <groupId>javax.annotation</groupId>
     <artifactId>javax.annotation-api</artifactId>
     <version>1.2</version>
</dependency>

解决:tomcat

选中项目“右击”,选择“Build path”,而后"Add Libraries",再选择“Server Runtime” ,在弹出的框中选择本身启动项目使用的server类型和版本便可消除报错maven

相关文章
相关标签/搜索