如何将servlet api添加到我的pom.xml中
如何将servlet API添加到项目的pom.xml
How do I add the servlets API to my project's pom.xml
mvnrepository.com有很多servlet api和类似命名的项目,我不知道哪个是正确的。或者它们都可以吗?
mvnrepository.com has lots of servlet api and similarly named projects, that I don't know which is the right one. Or are all of them ok?
我相信大多数网络/应用服务器捆绑了一个版本的servlet api,所以你不会想要在你的.war文件中捆绑api。您需要找出服务器附带的版本,然后您可以使用
I believe most web/app servers come bundled with a version of the servlet api, so you won't want to bundle the api in your .war file. You will need to find out which version is included with your server, then you can use
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
<scope>provided</scope>
</dependency>
用您的版本替换servlet-api-version。您需要指定提供的范围,以便api.jar不包含在您的war文件中。
replacing servlet-api-version with your version. You will want to specify the "provided" scope so the api.jar isn't included in your war file.