Nowadays, the projects are basically Java web projects, so there will be problems when importing jar packages. I will mainly introduce the difference between Java projects and Java web projects:
Java Project:
When classLoader loads jar and class, it is loaded separately. Generally, jar imports are divided into two types:
1. Directly introduce it in lib under web-inf
2.Introduced on user library
No matter which of the above is introduced, the jar package can be loaded and run, and the classLoader will load intelligently (local JRE runs)
javaweb project:
It is not run through local JRE, but is deployed to web servers (such as tomcat, jetty), which all implement their own class loaders.
Take tomcat as an example:
1.common CommonClassLoader
2.server CatalinaClassLoader
3.shared SharedClassLoader
4.webapps webappClassLoader (load jar under WEB-INF)
Simply put, if you introduce a jar package in a javaweb project, you need to import the jar package into WEB-INF, so that the server can load and when the project runs, the project method can also be called. If it is put into the user library, it is not possible, because it can only run locally and the server cannot load. Therefore, there is no problem when the project calls the method locally, but when the server runs, it will report that the corresponding jar cannot be found.
The above article briefly talks about the difference between java projects and javaweb projects importing jar packages is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.