In recent projects, all of the package-dependent management has been handed over to Maven, and prior to the idea, Jsp-api and Servlet-api have been added to the global Libraries, and the project is under construction and has been forgotten in global Add maven and then re-write the dependency at runtime results reported an exception, and then a want to simply remove the global Tomcat API all managed by MAVEN, it seems that everything is okay, But in calling the Httpservletrequest.getservletcontext times wrong, function not found it made me very confused when I was wondering if the package Maven added was not the same as the package under Tomcat Lib, that Maven Management Pack is not meaningless, tossing and turning no fruit, see the following detailed problem description:
First, through the MAVEN import Servelt-api when using the Httpservletrequest.getservletcontext method, the idea hint did not find the corresponding method, by mapping to the source code discovery did not, such as
Pom.xml Configuration
<dependency> <groupId>javax.servlet</groupId> <artifactid>servlet-api</ Artifactid> <version>3.0-alpha-1</version></dependency>
Tomcat and JDK
Second, by modifying the Servlet-api dependency to the local tomcat/lib in the jar package problem does not exist
Here, see the person may want to ask, why is using the alpha version of the API, then I really lazy, because 3.0.1 version of the warehouse in Nuxeo releases a want to update maven warehouse really don't want to, too slow!
After the toss, no way to slow also try, update the Nuxeo warehouse, according to the dependency should be the problem, but did not think of it is also MAVEN library has not seen the 3.0.1 jar package introduced, baffled its solution.
<dependency> <groupId>javax.servlet</groupId> <artifactid>servlet-api</ Artifactid> <version>3.0.1</version></dependency>
Online various search, did not find anything useful, in a return to the warehouse, found a big red box wrote a sentence
So dependency should be (Artifactid modified to JAVAX.SERVLET-API)
<dependency> <groupId>javax.servlet</groupId> <artifactid>javax.servlet-api </artifactId> <version>3.0.1</version></dependency>
Problem solving, self-refuting a start Maven package introduces different paradoxes of the package!
Summary: 1. Careless!
2. Try to avoid selecting the alpha bag in the selection package.
About the problem with the MAVEN load pack of carelessness