概述
每一个应用都会引入很多依赖jar包,而且其中大多数都是相同的,这样会导致部署时会花费很长的时间。瘦身部署指的是将第三方jar包依赖剔除,只保留业务接口依赖jar包进行打包部署。
剔除第三方依赖jar包
...
maven-war-plugin
3.2.2
WEB-INF/lib/commons-logging-*.jar,
%regex[^WEB-INF/lib/bussiness-(?!webapp-1|webapp-2).*.jar]
...
Tomcat共享类加载器
【1】catalina.properties 文件
# List of comma-separated paths defining the contents of the "shared"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
# the "common" loader will be used as Catalina‘s "shared" loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
# Please note that for single jars, e.g. bar.jar, you need the URL form
# starting with file:.
#
# Note: Values may be enclosed in double quotes ("...") in case either the
# ${catalina.base} path or the ${catalina.home} path contains a comma.
# Because double quotes are used for quoting, the double quote character
# may not appear in a path.
shared.loader="${catalina.base}/shared","${catalina.base}/shared/*.jar","${catalina.home}/shared","${catalina.home}/shared/*.jar"
【2】创建 shared 目录将第三方jar包放到这里
参考