Discussion on the differences between java project and javaweb Project import jar package

  • 2020-11-25 07:16:24
  • OfStack

The current projects are basically java web projects, so there will be some problems when importing jar package. The differences between java project and javaweb project are mainly introduced below:

java projects:

When classLoader loads jar and class, it is loaded separately. Generally, there are two types of jar imports:

1. Directly introduced in lib under ES17en-ES18en

2. Introduced on user library

Either way, the jar package loads and runs, and the classLoader package loads intelligently (local JRE runs)

javaweb projects:

Instead of running from local JRE, it is deployed to web servers (such as tomcat,jetty), which implement their own classloaders.

Take tomcat for example:

1.common CommonClassLoader

2.server CatalinaClassLoader

3.shared SharedClassLoader

4.webapps webappClassLoader(load jar under ES54en-ES55en)

To put it simply, when introducing the jar package for javaweb project, you need to import the jar package into ES62en-ES63en, so that the server can load and when the project is running, the method of the project can also be called. If you put it into user library, it is not possible, because it can only run locally, and the server cannot load it. So the project calls the method locally with no problem, but the server runs and reports that it can't find the corresponding jar.


Related articles: