Today, when developing the Web, you need to use the SERVLET-API, and then add the dependencies in the Pom.xml
<Dependency> <groupId>Javax.servlet</groupId> <Artifactid>Servlet-api</Artifactid> <version>3.0-alpha-1</version> </Dependency>
When you start Tomcat via the plugin, an error is included:
for a different type with the name "Javax/servlet/servletcontext" at Java.lang.ClassLoader.defineClass1 ( Native Method) at java.lang.ClassLoader.defineClass (classloader.java: Java.security.SecureClassLoader.defineClass (Secureclassloader.java:142) at Java.net.URLClassLoader.defineClass (URLClassLoader.java:449) at java.net.urlclassloader.access$ (urlclassloader.java:71) at java.net.urlclassloader$1.run (urlclassloader.java:361) At java.net.urlclassloader$ 1.run (urlclassloader.java:355)
The reason for this is that there are also servlet-api packages in Tomcat, so that there is a conflict
Workaround: Add <scope>provided</scope>, because provided indicates that the package is only used when compiling and testing, so when Tomcat is started, it does not conflict, and the complete dependency is as follows:
<Dependency> <groupId>Javax.servlet</groupId> <Artifactid>Servlet-api</Artifactid> <version>3.0-alpha-1</version> <Scope>Provided</Scope> </Dependency>
About <scope>provided</scope> use in Maven dependencies