tomcat下的公共jar包配置

本文详细介绍了如何在Tomcat服务器中进行必要的配置以增强安全性及优化性能。包括如何设置包访问限制、定义类加载路径以及排除扫描特定JAR文件等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1。创建my-lib文件夹

.

在conf文件中的catalina.properties中配置如下

  1 # Licensed to the Apache Software Foundation (ASF) under one or more
  2 # contributor license agreements.  See the NOTICE file distributed with
  3 # this work for additional information regarding copyright ownership.
  4 # The ASF licenses this file to You under the Apache License, Version 2.0
  5 # (the "License"); you may not use this file except in compliance with
  6 # the License.  You may obtain a copy of the License at
  7 #
  8 #     http://www.apache.org/licenses/LICENSE-2.0
  9 #
 10 # Unless required by applicable law or agreed to in writing, software
 11 # distributed under the License is distributed on an "AS IS" BASIS,
 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 # See the License for the specific language governing permissions and
 14 # limitations under the License.
 15 
 16 #
 17 # List of comma-separated packages that start with or equal this string
 18 # will cause a security exception to be thrown when
 19 # passed to checkPackageAccess unless the
 20 # corresponding RuntimePermission ("accessClassInPackage."+package) has
 21 # been granted.
 22 package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
 23 #
 24 # List of comma-separated packages that start with or equal this string
 25 # will cause a security exception to be thrown when
 26 # passed to checkPackageDefinition unless the
 27 # corresponding RuntimePermission ("defineClassInPackage."+package) has
 28 # been granted.
 29 #
 30 # by default, no packages are restricted for definition, and none of
 31 # the class loaders supplied with the JDK call checkPackageDefinition.
 32 #
 33 package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
 34 
 35 #
 36 #
 37 # List of comma-separated paths defining the contents of the "common"
 38 # classloader. Prefixes should be used to define what is the repository type.
 39 # Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
 40 # If left as blank,the JVM system loader will be used as Catalina's "common"
 41 # loader.
 42 # Examples:
 43 #     "foo": Add this folder as a class repository
 44 #     "foo/*.jar": Add all the JARs of the specified folder as class
 45 #                  repositories
 46 #     "foo/bar.jar": Add bar.jar as a class repository
 47 common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
 48 
 49 #
 50 # List of comma-separated paths defining the contents of the "server"
 51 # classloader. Prefixes should be used to define what is the repository type.
 52 # Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
 53 # If left as blank, the "common" loader will be used as Catalina's "server"
 54 # loader.
 55 # Examples:
 56 #     "foo": Add this folder as a class repository
 57 #     "foo/*.jar": Add all the JARs of the specified folder as class
 58 #                  repositories
 59 #     "foo/bar.jar": Add bar.jar as a class repository
 60 server.loader=
 61 
 62 #
 63 # List of comma-separated paths defining the contents of the "shared"
 64 # classloader. Prefixes should be used to define what is the repository type.
 65 # Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
 66 # the "common" loader will be used as Catalina's "shared" loader.
 67 # Examples:
 68 #     "foo": Add this folder as a class repository
 69 #     "foo/*.jar": Add all the JARs of the specified folder as class
 70 #                  repositories
 71 #     "foo/bar.jar": Add bar.jar as a class repository
 72 # Please note that for single jars, e.g. bar.jar, you need the URL form
 73 # starting with file:.
 74 shared.loader=${catalina.base}/my-lib,${catalina.base}/my-lib/*.jar
 75 # List of JAR files that should not be scanned using the JarScanner
 76 # functionality. This is typically used to scan JARs for configuration
 77 # information. JARs that do not contain such information may be excluded from
 78 # the scan to speed up the scanning process. This is the default list. JARs on
 79 # this list are excluded from all scans. Scan specific lists (to exclude JARs
 80 # from individual scans) follow this. The list must be a comma separated list of
 81 # JAR file names.
 82 # The JARs listed below include:
 83 # - Tomcat Bootstrap JARs
 84 # - Tomcat API JARs
 85 # - Catalina JARs
 86 # - Jasper JARs
 87 # - Tomcat JARs
 88 # - Common non-Tomcat JARs
 89 # - Test JARs (JUnit, Cobertura and dependencies)
 90 tomcat.util.scan.DefaultJarScanner.jarsToSkip=\
 91 bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\
 92 annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,\
 93 catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\
 94 jasper.jar,jasper-el.jar,ecj-*.jar,\
 95 tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\
 96 tomcat-jni.jar,tomcat-spdy.jar,\
 97 tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
 98 tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\
 99 tomcat-jdbc.jar,\
100 tools.jar,\
101 commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\
102 commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\
103 commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\
104 commons-math*.jar,commons-pool*.jar,\
105 jstl.jar,\
106 geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\
107 ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\
108 jmx-tools.jar,jta*.jar,log4j.jar,log4j-1*.jar,mail*.jar,slf4j*.jar,\
109 xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\
110 junit.jar,junit-*.jar,hamcrest*.jar,org.hamcrest*.jar,ant-launcher.jar,\
111 cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,\
112 jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,\
113 xom-*.jar
114 
115 # Additional JARs (over and above the default JARs listed above) to skip when
116 # scanning for Servlet 3.0 pluggability features. These features include web
117 # fragments, annotations, SCIs and classes that match @HandlesTypes. The list
118 # must be a comma separated list of JAR file names.
119 org.apache.catalina.startup.ContextConfig.jarsToSkip=
120 
121 # Additional JARs (over and above the default JARs listed above) to skip when
122 # scanning for TLDs. The list must be a comma separated list of JAR file names.
123 org.apache.catalina.startup.TldConfig.jarsToSkip=tomcat7-websocket.jar
124 
125 #
126 # String cache configuration.
127 tomcat.util.buf.StringCache.byte.enabled=true
128 #tomcat.util.buf.StringCache.char.enabled=true
129 #tomcat.util.buf.StringCache.trainThreshold=500000
130 #tomcat.util.buf.StringCache.cacheSize=5000

 

转载于:https://www.cnblogs.com/haiyangsvs/p/7839209.html

================================================================================ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================================================ Apache Tomcat Version 8.0.15 Release Notes ========= CONTENTS: ========= * Dependency Changes * API Stability * Bundled APIs * Web application reloading and static fields in shared libraries * Security manager URLs * Symlinking static resources * Viewing the Tomcat Change Log * Cryptographic software notice * When all else fails =================== Dependency Changes: =================== Tomcat 8.0 is designed to run on Java SE 7 and later. ============== API Stability: ============== The public interfaces for the following classes are fixed and will not be changed at all during the remaining lifetime of the 8.x series: - All classes in the javax namespace The public interfaces for the following classes may be added to in order to resolve bugs and/or add new features. No existing interface method will be removed or changed although it may be deprecated. - org.apache.catalina.* (excluding sub-packages) Note: As Tomcat 8 matures, the above list will be added to. The list is not c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值