• tomcat加载外部项目


    一般的项目都是放到webapps下的,我们这里做一个外部配置
    <?xml version='1.0' encoding='utf-8'?>
    <Server port="2001" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
      <Listener className="org.apache.catalina.core.JasperListener" />
      <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
      <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
      <GlobalNamingResources>
        <Resource name="UserDatabase" auth="Container"
                  type="org.apache.catalina.UserDatabase"
                  description="User database that can be updated and saved"
                  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                  />
      </GlobalNamingResources>
      <Service name="Catalina">
      
        <Connector port="8081" protocol="HTTP/1.1"
                   connectionTimeout="20000"
            maxThreads="3000" 
            maxPostSize="-1" 
            maxHttpHeaderSize ="102400" 
                   minSpareThreads="250" 
                   acceptCount="2000" 
                   enableLookups="false" 
                   compression="on" 
                   URIEncoding="UTF-8"
                   compressionMinSize="2048" 
                   noCompressionUserAgents="gozilla,traviata" 
                   compressableMimeType="text/html,text/xml,text/css,text/plain,text/javascript,application/x-javascript,application/javascript" 
                   />
                   
        <Engine name="Catalina" defaultHost="localhost">
          <Realm className="org.apache.catalina.realm.LockOutRealm">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase"/>
          </Realm>
                <Host 
                    name="localhost" 
                    appBase="webapps" 
                    unpackWARs="true" 
                    autoDeploy="true"
                    xmlValidation="false" 
                    xmlNamespaceAware="false">
    
                    <Context 
                        path=""  //这里放空就行
                        docBase="/data/rs" //项目路径,可以写绝对,也可以写相对,相对的自己更具自己的项目位置修改
                        allowLinking="true" 
                        reloadable="false"
                        privileged="true" >
                    </Context>
    <!--        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log." suffix=".txt"
                   pattern="%h %l %u %t &quot;%r&quot; %s %b" /> -->
    
          </Host>
        </Engine>
      </Service>
    </Server>
    如果启动出现问题
    java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.Life, ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].
    StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:
    154)
at
    org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at
    org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1090)
at
    org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1900)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at
    java.util.concurrent.FutureTask.run(FutureTask.java:262)

    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina

    
    
    解决方法:
     更改tomcat配置文件catalina.properties。
      tomcat.util.scan.DefaultJarScanner.jarsToSkip= 值后面加",*"
    
    
    启动界面乱码
    修改日志配置文件logging.properties中的控制台编码
    
    java.util.logging.ConsoleHandler.level = FINE
    java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
    java.util.logging.ConsoleHandler.encoding = GBK
  • 相关阅读:
    java学习day51--DB旅游生态系统-项目搭建
    java学习day50--Spring Boot发送邮件任务
    java学习day49--yaml语法以及注入
    java学习day49--JSON扩展(详细)
    java学习day49--JS数组遍历
    java学习day49-基于AJAX实践操作(活动模块)
    java学习day48--Ajax技术--原生
    denied: requested access to the resource is denied
    VMware虚拟机网络适配器三种网络连接模式
    MySQL8.0.19最新版本rpm包和源码包百度地址
  • 原文地址:https://www.cnblogs.com/renjianjun/p/13531414.html
Copyright © 2020-2023  润新知