简体   繁体   English

在Eclipse中添加外部库

[英]Adding external libraries in Eclipse

I create new projects in Eclipse regularly and every time when I add a Servlet to one of them I get the error import javax.servlet can't be resolved 我定期在Eclipse中创建新项目,每次将Servlet添加到其中一个项目时,都会收到错误import javax.servlet can't be resolved

To solve this I have to add a jar to the project. 为了解决这个问题,我必须在项目中添加一个jar。

So is there any method such that the required JARs are added to all of my projects ,ie, I don't have to add them again and again whenever I create a new project. 有什么方法可以将所需的JAR添加到我的所有项目中,即,我创建新项目时不必一次又一次地添加它们。

You should be using Eclipse IDE for Java EE Developers and creating each project as a Dynamic Web Project . 您应该将Eclipse IDE for Java EE Developers并将每个项目创建为Dynamic Web Project It will ask you which container you are using (like Apache Tomcat 7.0.x ), but it will add the necessary JARs to the classpath for you. 它将询问您正在使用哪个容器(例如Apache Tomcat 7.0.x ),但是它将为您添加必要的JAR到类路径。 Anything you drop in your WEB-INF/lib folder will also be added automatically to the classpath. 放在WEB-INF/lib文件夹中的所有内容也将自动添加到类路径中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM