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