About the problem with the MAVEN load pack of carelessness

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.