码迷,mamicode.com
首页 > 其他好文 > 详细

瘦身部署应用

时间:2019-03-06 10:35:07      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:ase   not   reg   conf   导致   sed   pac   html   highlight   

概述

  每一个应用都会引入很多依赖jar包,而且其中大多数都是相同的,这样会导致部署时会花费很长的时间。瘦身部署指的是将第三方jar包依赖剔除,只保留业务接口依赖jar包进行打包部署。

剔除第三方依赖jar包

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.2</version>
        <configuration>
          <!--
            Exclude JCL and LOG4J since all logging should go through SLF4J.
            Note that we‘re excluding log4j-<version>.jar but keeping
            log4j-over-slf4j-<version>.jar
          -->
          <packagingExcludes>
            WEB-INF/lib/commons-logging-*.jar,
            %regex[^WEB-INF/lib/bussiness-(?!webapp-1|webapp-2).*.jar]
          </packagingExcludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

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包放到这里

技术图片

技术图片

参考

http://maven.apache.org/plugins/maven-war-plugin/examples/including-excluding-files-from-war.html

 

瘦身部署应用

标签:ase   not   reg   conf   导致   sed   pac   html   highlight   

原文地址:https://www.cnblogs.com/BINGJJFLY/p/10481649.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!