Very often, the weight of the application that we put on the server reaches indecently large sizes due to the inclusion of all the necessary dependencies. In the end, my applications take from 20 to 50 meters. Depla such war-s on a remote server, on Tomcat, it's not one minute, and if you have a bad connection, it becomes problematic. Putting the library in $ {tomcat.home} / lib is very ungrateful and often dangerous. We at the company a little google and found a very pleasant solution on DZone. I want to share with you ...
I just want to say that the method is suitable primarily for those who breed their cats, and do not use the services of hosters ... although it all depends on which hoster offers a solution.
One person, someone Dapeng Liu, carefully reading the API documentation for Tomcat, implemented a very library that you can take
here . In fact, the library is the implementation of the application loader for the cat.
How it works:
- Put this library in $ {tomcat.home} / lib
- A repo folder is created in $ {catalina.home}. It creates folders with repositories. For example, when using hibernate, there is a dependency on several libraries. Create the $ {catalina.home} /repo/hibernate_3.3.0 directory into which we put all the necessary libraries. You can create a repository of a specific project at once and put all the necessary libraries there at once.
- Correct the context description for your application. Now it should look like this:
<Context path="/testapp">
<Loader className='com.spiralcomms.tomcat.WebappLoader' />
<lib>spring_2.5.6</lib>
<lib>hibernate_3.3.0</lib>
</Context>
- The application will be deployed by the specified bootloader. When the deployment starts, the loader will search all lib tags in the context, find repositories in the $ {catalina.home} / repo folder using them, and include them in the download.
')
Thus, applications drastically lose weight from 20-50 meters to one and a half to two, which greatly affects the speed of uploading it to the server.
Of course, such a process imposes a restriction on the developer. When uploading applications, he should know if any libraries have been added to the application in order to update the repository.
Personally, the method helps me a lot when there is a weak channel to the server and there is a close work with the customer regarding the application changes. It is required to make edits and upload them to the server up to 20 times a day.
PS The original description of the solution found can be read
here .