怎么给java代码瘦身_瘦身部署应用(示例代码)

概述

每一个应用都会引入很多依赖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包放到这里

20190306103507201436.png

20190306103507325451.png

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值