While working on the project in the previous period, the MAVEN project built with Eclipse was deployed under Tomcat and found that the Lib directory under Tomcat's Web-inf was empty, and it was a long time, and there was no way Just manually copy all the dependencies to the Web-inf Lib, but each time the deployment, the Eclipse automatic deployment and the Lib directory empty, then that called a depressed, then I looked at someone else's classpath file, found that my classpath and other people's different points
Figure 1:
Figure 2:
found that after adding the above attributes, the label, the normal deployment of the project, and Tomcat Lib also has the necessary jar.
Recently, someone asked why my JDBC driver can access the database normally in the main method, and when I deploy to Tomcat, I always report classnotfoundexception, I'm not able to find the driver class, I connected it remotely and found his tomcat Web-inf the following no MySQL driver package, but he was in the project in the form of Exteneral Jar added to the classpath, when deployed when Tomcat there is no jar, when the first feeling is classpath problem, Daoteng for a long time , finally solved, the solution is described in detail below (note: I use the eclipse version is Eclipse Jee 3.7 (Indigo), Tomcat 6.0.29):
The Tomcat default publishing project for Eclipse configuration is not deployed to the Tomcat installation directory, but to the \.metadata under your workspace directory \.plugins\org.eclipse.wst.server.core\ Tmp0\wtpwebapps This folder, this is why someone will ask why I clearly project deployment success, but I go to Tomcat under the webapp below but there is no I just released the project, in fact, take a look at the configuration, of course, before you change, your first will Tomcat The following own deployment of the project deleted, (Tomcat comes with a few doc,root, such as do not have to delete), double-click on the server Tomcat, will pop up the tomcat configuration, as above, we chose the second
Change the Wtpwebapps to the Tomcat default WebApps, save it so that when you deploy the project, the project will automatically be deployed to the Tomcat installation directory under WebApps, and now back to the release of the project Tomcat Web-inf Lib directory is empty, right click on Project, properties, select Deployment assembly option, click the Add button, such as:
In the popup dialog box, select Java Build path entries
Next, you add the external jar package.
After finish completes, after launching Tomcat, go to WebApp below to verify that the jar package is deployed with the project.
Eclipse deployment time does not copy jar package to Web-inf below the Lib directory solution