⒈忽略tomcat的context-path

  方式一:

    停止tomcat服务,删除tomcat安装目录的webapps目录下的ROOT目录,将打成的WAR包重命名为ROOT.war,重启tomcat服务,tomcat将自动解压部署。

  方式二:

    为当前war包指定context-path为/

    编辑tomcat安装目录的conf目录下的service.xml文件,在<Host>节点下添加如下内容

  1. <Context path="/" docBase="warName" debug="0" reloadable="true"></Context>

    完整代码如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9.  
  10. http://www.apache.org/licenses/LICENSE-2.0
  11.  
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. -->
  18. <!-- Note: A "Server" is not itself a "Container", so you may not
  19. define subcomponents such as "Valves" at this level.
  20. Documentation at /docs/config/server.html
  21. -->
  22. <Server port="8005" shutdown="SHUTDOWN">
  23. <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  24. <!-- Security listener. Documentation at /docs/config/listeners.html
  25. <Listener className="org.apache.catalina.security.SecurityListener" />
  26. -->
  27. <!--APR library loader. Documentation at /docs/apr.html -->
  28. <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  29. <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  30. <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  31. <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  32. <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  33.  
  34. <!-- Global JNDI resources
  35. Documentation at /docs/jndi-resources-howto.html
  36. -->
  37. <GlobalNamingResources>
  38. <!-- Editable user database that can also be used by
  39. UserDatabaseRealm to authenticate users
  40. -->
  41. <Resource name="UserDatabase" auth="Container"
  42. type="org.apache.catalina.UserDatabase"
  43. description="User database that can be updated and saved"
  44. factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
  45. pathname="conf/tomcat-users.xml" />
  46. </GlobalNamingResources>
  47.  
  48. <!-- A "Service" is a collection of one or more "Connectors" that share
  49. a single "Container" Note: A "Service" is not itself a "Container",
  50. so you may not define subcomponents such as "Valves" at this level.
  51. Documentation at /docs/config/service.html
  52. -->
  53. <Service name="Catalina">
  54.  
  55. <!--The connectors can use a shared executor, you can define one or more named thread pools-->
  56. <!--
  57. <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
  58. maxThreads="150" minSpareThreads="4"/>
  59. -->
  60.  
  61. <!-- A "Connector" represents an endpoint by which requests are received
  62. and responses are returned. Documentation at :
  63. Java HTTP Connector: /docs/config/http.html
  64. Java AJP Connector: /docs/config/ajp.html
  65. APR (HTTP/AJP) Connector: /docs/apr.html
  66. Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
  67. -->
  68. <Connector port="8080" protocol="HTTP/1.1"
  69. connectionTimeout="20000"
  70. redirectPort="8443" />
  71. <!-- A "Connector" using the shared thread pool-->
  72. <!--
  73. <Connector executor="tomcatThreadPool"
  74. port="8080" protocol="HTTP/1.1"
  75. connectionTimeout="20000"
  76. redirectPort="8443" />
  77. -->
  78. <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
  79. This connector uses the NIO implementation. The default
  80. SSLImplementation will depend on the presence of the APR/native
  81. library and the useOpenSSL attribute of the
  82. AprLifecycleListener.
  83. Either JSSE or OpenSSL style configuration may be used regardless of
  84. the SSLImplementation selected. JSSE style configuration is used below.
  85. -->
  86. <!--
  87. <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
  88. maxThreads="150" SSLEnabled="true">
  89. <SSLHostConfig>
  90. <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
  91. type="RSA" />
  92. </SSLHostConfig>
  93. </Connector>
  94. -->
  95. <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
  96. This connector uses the APR/native implementation which always uses
  97. OpenSSL for TLS.
  98. Either JSSE or OpenSSL style configuration may be used. OpenSSL style
  99. configuration is used below.
  100. -->
  101. <!--
  102. <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
  103. maxThreads="150" SSLEnabled="true" >
  104. <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
  105. <SSLHostConfig>
  106. <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
  107. certificateFile="conf/localhost-rsa-cert.pem"
  108. certificateChainFile="conf/localhost-rsa-chain.pem"
  109. type="RSA" />
  110. </SSLHostConfig>
  111. </Connector>
  112. -->
  113.  
  114. <!-- Define an AJP 1.3 Connector on port 8009 -->
  115. <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
  116.  
  117. <!-- An Engine represents the entry point (within Catalina) that processes
  118. every request. The Engine implementation for Tomcat stand alone
  119. analyzes the HTTP headers included with the request, and passes them
  120. on to the appropriate Host (virtual host).
  121. Documentation at /docs/config/engine.html -->
  122.  
  123. <!-- You should set jvmRoute to support load-balancing via AJP ie :
  124. <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
  125. -->
  126. <Engine name="Catalina" defaultHost="localhost">
  127.  
  128. <!--For clustering, please take a look at documentation at:
  129. /docs/cluster-howto.html (simple how to)
  130. /docs/config/cluster.html (reference documentation) -->
  131. <!--
  132. <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
  133. -->
  134.  
  135. <!-- Use the LockOutRealm to prevent attempts to guess user passwords
  136. via a brute-force attack -->
  137. <Realm className="org.apache.catalina.realm.LockOutRealm">
  138. <!-- This Realm uses the UserDatabase configured in the global JNDI
  139. resources under the key "UserDatabase". Any edits
  140. that are performed against this UserDatabase are immediately
  141. available for use by the Realm. -->
  142. <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
  143. resourceName="UserDatabase"/>
  144. </Realm>
  145.  
  146. <Host name="localhost" appBase="webapps"
  147. unpackWARs="true" autoDeploy="true">
  148.  
  149. <!-- SingleSignOn valve, share authentication between web applications
  150. Documentation at: /docs/config/valve.html -->
  151. <!--
  152. <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
  153. -->
  154.  
  155. <!-- Access log processes all example.
  156. Documentation at: /docs/config/valve.html
  157. Note: The pattern used is equivalent to using pattern="common" -->
  158. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  159. prefix="localhost_access_log" suffix=".txt"
  160. pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  161. <Context path="/" docBase="warName" debug="0" reloadable="true"></Context>
  162. </Host>
  163. </Engine>
  164. </Service>
  165. </Server>

  方式三:

  将Host节点的appBase属性设置为空,添加Context节点,将reloadable属性设置为false

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9.  
  10. http://www.apache.org/licenses/LICENSE-2.0
  11.  
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. -->
  18. <!-- Note: A "Server" is not itself a "Container", so you may not
  19. define subcomponents such as "Valves" at this level.
  20. Documentation at /docs/config/server.html
  21. -->
  22. <Server port="8005" shutdown="SHUTDOWN">
  23. <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  24. <!-- Security listener. Documentation at /docs/config/listeners.html
  25. <Listener className="org.apache.catalina.security.SecurityListener" />
  26. -->
  27. <!--APR library loader. Documentation at /docs/apr.html -->
  28. <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  29. <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  30. <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  31. <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  32. <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  33.  
  34. <!-- Global JNDI resources
  35. Documentation at /docs/jndi-resources-howto.html
  36. -->
  37. <GlobalNamingResources>
  38. <!-- Editable user database that can also be used by
  39. UserDatabaseRealm to authenticate users
  40. -->
  41. <Resource name="UserDatabase" auth="Container"
  42. type="org.apache.catalina.UserDatabase"
  43. description="User database that can be updated and saved"
  44. factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
  45. pathname="conf/tomcat-users.xml" />
  46. </GlobalNamingResources>
  47.  
  48. <!-- A "Service" is a collection of one or more "Connectors" that share
  49. a single "Container" Note: A "Service" is not itself a "Container",
  50. so you may not define subcomponents such as "Valves" at this level.
  51. Documentation at /docs/config/service.html
  52. -->
  53. <Service name="Catalina">
  54.  
  55. <!--The connectors can use a shared executor, you can define one or more named thread pools-->
  56. <!--
  57. <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
  58. maxThreads="150" minSpareThreads="4"/>
  59. -->
  60.  
  61. <!-- A "Connector" represents an endpoint by which requests are received
  62. and responses are returned. Documentation at :
  63. Java HTTP Connector: /docs/config/http.html
  64. Java AJP Connector: /docs/config/ajp.html
  65. APR (HTTP/AJP) Connector: /docs/apr.html
  66. Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
  67. -->
  68. <Connector port="10005" protocol="HTTP/1.1"
  69. connectionTimeout="20000"
  70. redirectPort="8443" maxPostSize="-1" />
  71. <!-- A "Connector" using the shared thread pool-->
  72. <!--
  73. <Connector executor="tomcatThreadPool"
  74. port="8080" protocol="HTTP/1.1"
  75. connectionTimeout="20000"
  76. redirectPort="8443" />
  77. -->
  78. <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
  79. This connector uses the NIO implementation. The default
  80. SSLImplementation will depend on the presence of the APR/native
  81. library and the useOpenSSL attribute of the
  82. AprLifecycleListener.
  83. Either JSSE or OpenSSL style configuration may be used regardless of
  84. the SSLImplementation selected. JSSE style configuration is used below.
  85. -->
  86. <!--
  87. <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
  88. maxThreads="150" SSLEnabled="true">
  89. <SSLHostConfig>
  90. <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
  91. type="RSA" />
  92. </SSLHostConfig>
  93. </Connector>
  94. -->
  95. <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
  96. This connector uses the APR/native implementation which always uses
  97. OpenSSL for TLS.
  98. Either JSSE or OpenSSL style configuration may be used. OpenSSL style
  99. configuration is used below.
  100. -->
  101. <!--
  102. <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
  103. maxThreads="150" SSLEnabled="true" >
  104. <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
  105. <SSLHostConfig>
  106. <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
  107. certificateFile="conf/localhost-rsa-cert.pem"
  108. certificateChainFile="conf/localhost-rsa-chain.pem"
  109. type="RSA" />
  110. </SSLHostConfig>
  111. </Connector>
  112. -->
  113.  
  114. <!-- Define an AJP 1.3 Connector on port 8009 -->
  115. <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
  116.  
  117. <!-- An Engine represents the entry point (within Catalina) that processes
  118. every request. The Engine implementation for Tomcat stand alone
  119. analyzes the HTTP headers included with the request, and passes them
  120. on to the appropriate Host (virtual host).
  121. Documentation at /docs/config/engine.html -->
  122.  
  123. <!-- You should set jvmRoute to support load-balancing via AJP ie :
  124. <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
  125. -->
  126. <Engine name="Catalina" defaultHost="localhost">
  127.  
  128. <!--For clustering, please take a look at documentation at:
  129. /docs/cluster-howto.html (simple how to)
  130. /docs/config/cluster.html (reference documentation) -->
  131. <!--
  132. <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
  133. -->
  134.  
  135. <!-- Use the LockOutRealm to prevent attempts to guess user passwords
  136. via a brute-force attack -->
  137. <Realm className="org.apache.catalina.realm.LockOutRealm">
  138. <!-- This Realm uses the UserDatabase configured in the global JNDI
  139. resources under the key "UserDatabase". Any edits
  140. that are performed against this UserDatabase are immediately
  141. available for use by the Realm. -->
  142. <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
  143. resourceName="UserDatabase"/>
  144. </Realm>
  145.  
  146. <Host name="localhost" appBase=""
  147. unpackWARs="true" autoDeploy="true">
  148.  
  149. <!-- SingleSignOn valve, share authentication between web applications
  150. Documentation at: /docs/config/valve.html -->
  151. <!--
  152. <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
  153. -->
  154.  
  155. <!-- Access log processes all example.
  156. Documentation at: /docs/config/valve.html
  157. Note: The pattern used is equivalent to using pattern="common" -->
  158. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  159. prefix="localhost_access_log" suffix=".txt"
  160. pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  161. <Context path="" docBase="webapps/DeductGoodsManagerment" debug="0" reloadable="false"></Context>
  162.  
  163. </Host>
  164. </Engine>
  165. </Service>
  166. </Server>

⒉新版Tomcat Cookies问题

  错误问题:An invalid character [32] was present in the Cookie value

  错误原因:Cookies中包含不被允许的空格。

  错误截图:

  引发此问题讨论的stackoverflow:https://stackoverflow.com/questions/38687210/error-with-cookie-value-when-adding-a-new-spring-session

  解决方案:

    将tomcat新版的cookies解决指定为旧版本的cookies解决方案。

    停止tomcat服务,打开tomcat安装目录下的conf/context.xml文件,增加以下内容

  1. <CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />

    完整配置文件如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9.  
  10. http://www.apache.org/licenses/LICENSE-2.0
  11.  
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. -->
  18. <!-- The contents of this file will be loaded for each web application -->
  19. <Context>
  20.  
  21. <!-- Default set of monitored resources. If one of these changes, the -->
  22. <!-- web application will be reloaded. -->
  23. <WatchedResource>WEB-INF/web.xml</WatchedResource>
  24. <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
  25. <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
  26. <CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
  27.  
  28. <!-- Uncomment this to disable session persistence across Tomcat restarts -->
  29. <!--
  30. <Manager pathname="" />
  31. -->
  32. </Context>

⒊tomcat启动时指定springboot配置

⒋前端  Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.  错误

  错误截图

  

  解决方案:

    在host文件中指定一个域名指向本地127.0.0.1,通过该域名访问本地调试网站。

SpringBoot以WAR包部署遇到的坑---集合贴的更多相关文章

  1. SpringBoot项目war包部署

    服务部署 记录原因 将本地SpringBoot项目通过war包部署到虚拟机中,验证服务器部署. 使用war包是为了方便替换配置文件等. 工具 对象 版本 Spring Boot 2.4.0 VMwar ...

  2. springboot项目war包部署及出现的问题Failed to bind properties under 'mybatis.configuration.mapped-statements[0].

    1.修改pom文件 修改打包方式 为war: 添加tomcat使用范围,provided的意思即在发布的时候有外部提供,内置的tomcat就不会打包进去 <groupId>com.scho ...

  3. springBoot 项目war包部署及改为war包后资源路径错误问题

    参考资料: https://blog.csdn.net/rico_zhou/article/details/83415114 https://blog.csdn.net/pz641/article/d ...

  4. springboot打war包部署tomcat服务器,以及表单提交数据乱码处理

    小白觉得springboot打成jar包直接使用内嵌的tomcat或jetty容器(java -jar xxx.jar)运行项目不利于定位问题,我还是习惯于查看tomcat或nginx的日志来定位问题 ...

  5. 通过一次SpringBoot打成war包部署到tomcat启动总结一般jar包冲突的解决方法

    启动时,报错信息如下: 28-Sep-2018 16:55:41.567 严重 [localhost-startStop-1] org.apache.catalina.core.StandardCon ...

  6. springboot打包war包部署到tomcat

    1.pom.xml修改处 <modelVersion>4.0.0</modelVersion><groupId>com.xx</groupId>< ...

  7. springboot打war包部署到tomcat

    1:build.gradle plugins { id 'org.springframework.boot' version '2.1.5.RELEASE' id 'java' } apply plu ...

  8. springboot 使用war包部署

    ps://www.cnblogs.com/jiaoyiping/p/4251718.html

  9. SpringBoot之打成war包部署到Tomcat

    正常情况下SpringBoot项目是以jar包的形式,正常情况下SpringBoot项目是以jar包的形式,并且SpringBoot是内嵌Tomcat服务器,所以每次重新启动都是用的新的Tomcat服 ...

随机推荐

  1. python 小游戏 “外星飞船入侵”

    Project Title 项目名称 “外星飞船入侵”, git地址:https://github.com/lilinyu861/Alien-Invasion 效果图: 参考: https://blo ...

  2. linux中如何修改最大文件句柄数

    1.使用ulimit -a可以查看,其中的open files后面的数就是最大文件句柄数 2.临时方法:使用ulimit -n size修改最大文件句柄数(这种方法只针对当前进程有效) 3.永久方法: ...

  3. sql文件导入老是失败

    这是因为sql文件中的编码格式与库的格式不一致造成的,遇到这种问题先进入sql文件看看其编程格式是什么后再建立库的格式一般我们建立库都只选择utf-8下面的格式都没有选择

  4. wqy的C题

    wqy的C题 毒瘤! 题意: 你有一张 $ n $ 个点 $ m $ 条边的无向图. 你想在这张图上添加 $ n $ 条有向边,每一条有向边连接两个点 $ u,v $ ,你需要保证 $ u,v $ 在 ...

  5. Qt for Android (二) Qt打开android的相册

    以下有一个可以用的Demo https://files.cnblogs.com/files/wzxNote/Qt-Android-Gallery-master.zip 网盘地址: https://pa ...

  6. Qt for Android(一)Qt在Android手机上全屏显示

    1.在程序的编译路径下找到AndroidManifest.xml文件,具体路径如下: 2.在pro文件中添加一句话: ANDROID_PACKAGE_SOURCE_DIR = $$PWD/Androi ...

  7. AtomicInteger原理

    AtomicInteger的原理 java的并发原子包里面提供了很多可以进行原子操作的类,比如: AtomicInteger AtomicBoolean AtomicLong AtomicRefere ...

  8. Vue 目录

    什么是 vue-cli 通过 vue-cli 建立出来的 vue

  9. 五子棋AI教程

    https://github.com/Chuck-Ai/gobang 我写了非常详细的中文教程,教你如何一步步编写自己的五子棋AI: 五子棋AI设计教程第二版一:前言 五子棋AI设计教程第二版二:博弈 ...

  10. mysql 给用户设置权限

    grant   all   on   wordpress.*   to  wordpress@'10.0.0.%'  identified  by  'wordpress'; all    全部权限 ...