zoukankan      html  css  js  c++  java
  • 瘦身部署应用

    概述

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

    tomcat下多个项目可能依赖同一类jar包不同版本号(jar冲突)

      【1】既然是共享的jar包,共享的则是多个项目依赖的同一个jar包(版本号一致),不同的jar包仍然放在各自项目的lib目录下

      【2】参考:https://www.cnblogs.com/jym-sunshine/p/4859248.html

    参考

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

  • 相关阅读:
    SVM+HOG特征训练分类器
    数字图像处理的基本原理和常用方法
    c++中二进制和整数转化
    目标检测——HOG特征
    相似图片搜索的原理和实现——颜色分布法
    测试文本文件大小
    Direct2D 图形计算
    Direct2D 如何关闭抗锯齿
    MFC窗口显隐
    CISP/CISA 每日一题 22
  • 原文地址:https://www.cnblogs.com/BINGJJFLY/p/10481649.html
Copyright © 2011-2022 走看看