SpringBoot项目打包成war包 访问路径不用加项目名

SpringBoot项目打包成war包 访问路径不用加项目名

需求:把springboot打包成war包,在打包后,我们把这个war包放到tomcat的webapps下。但是在启动tomcat后,需要加上项目名才能访问,不然会出现404错误,解决如下:

  1. 进入 tomcat - conf - server.xml
  2. 添加Context配置:
 <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
      <!--added here  -->
      <Context path="" docBase="你的项目名" reloadable="true"/>
</Host>
  1. 但是感觉不是一个长久的方法,希望有更好的解决方案。
posted @ 2022-08-22 17:30  A07_xxxx  阅读(94)  评论(0)    收藏  举报