springboot 部署到tomcat6遇到404的问题

springboot 部署到tomcat6遇到404的问题,其实是因为springboot只支持servlet2.5以上的,tomcat6是2.5以下的导致报错,参考如下网址:

bdbrowser://snapshot/?cache=http%3A%2F%2Fcache.baiducontent.com%2Fc%3Fm%3D9f65cb4a8c8507ed50f0893b4853cb374504de3e6996cc44228b8e0dc43f111f1c21fef93a261605d3c47a671df50f03b4%26newp%3D8e609a15809301f21dacc33e6014&url=http%3A%2F%2Fwww.cnblogs.com%2Fweixliu%2Fp%2F6432342.html

https://blog.csdn.net/gege87417376/article/details/79204183

   注:如果你的tomcat是tomcat6版本,那很大可能你会遇到如下两个问题:

第一个问题是: 当你按照网上的配置,配置tomcat时,放在tomcat6下面,会遇到如下问题,我的解决方案是删除掉webapps对应项目lib文件夹下的tomcat-embed-core-8.5,但是启动仍然报错,接着看下一步:

信息: validateJarFile(D:\allone\ex2.6\Ex02-Bank\tomcat6113\webapps\RuoYi\WEB-INF\lib\tomcat-embed-core-8.5.31.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

    这个上面的文章有说:是因为

     所以当我遇到这个问题之后,我尝试更换成tomcat8,不需要额外配置web.xml或者引入


   启动就正常,就能够访问项目了.总结一下当你遇到404的错误时,请先确认一下你的tomcat是否为8,请更换成tomcat8,即可解决问题:

   注意别忘了在tomcat的server.xml配置的你的项目war包名称:


   我的启动java类和pom.xml文件如下:

package com.ruoyi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
 * web容器中进行部署
 * 
 * @author ruoyi
 */
public class RuoYiServletInitializer extends SpringBootServletInitializer
{
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
    {
        return application.sources(RuoYiApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(RuoYiServletInitializer.class, args);
    }

}
 
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.ruoyi</groupId>
   <artifactId>RuoYi</artifactId>
   <version>2.0.0</version>
   <!--<packaging>jar</packaging>-->
   <packaging>war</packaging>

   <name>RuoYi</name>
   <description>江湾党建管理系统</description>

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.3.RELEASE</version>
      <relativePath />
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      <shiro.version>1.3.2</shiro.version>
      <thymeleaf.extras.shiro.version>2.0.0</thymeleaf.extras.shiro.version>
      <mybatis.spring.boot.starter.version>1.1.1</mybatis.spring.boot.starter.version>
      <pagehelper.spring.boot.starter.version>1.2.3</pagehelper.spring.boot.starter.version>
      <fastjson.version>1.2.31</fastjson.version>
      <druid.version>1.0.28</druid.version>
      <commons.io.version>2.5</commons.io.version>
      <commons.fileupload.version>1.3.3</commons.fileupload.version>
      <bitwalker.version>1.19</bitwalker.version>
      <lombok.version>1.16.18</lombok.version>
      <velocity.version>1.7</velocity.version>
      <kaptcha.version>2.3.2</kaptcha.version>
      <swagger.version>2.7.0</swagger.version>
      <jsoup.version>1.11.3</jsoup.version>
   </properties>

   <dependencies>

      <!-- SpringBoot 核心包 -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter</artifactId>
         <!-- tomcat发布所需 -->
           <exclusions>
                <exclusion>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <groupId>org.springframework.boot</groupId>
                </exclusion>
            </exclusions>
            
      </dependency>
      
      <!-- tomcat发布所需 -->
       <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.1.0</version>
          <scope>provided</scope>
      </dependency>

      <!--打包tomcat所使用-->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-legacy</artifactId>
         <version>1.1.0.RELEASE</version>
      </dependency>


      <!-- SpringBoot 测试 -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>

      <!-- SpringBoot 拦截器 -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-aop</artifactId>
      </dependency>

      <!-- SpringBoot Web容器 -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <!-- SpringBoot集成thymeleaf模板 -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>

      <!-- spring-boot-devtools -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-devtools</artifactId>
         <optional>true</optional> <!-- 表示依赖不会传递 -->
      </dependency>

      <!-- thymeleaf网页解析 -->
      <dependency>
         <groupId>net.sourceforge.nekohtml</groupId>
         <artifactId>nekohtml</artifactId>
      </dependency>

      <!-- Mysql驱动包 -->
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
      </dependency>

      <!-- SpringBoot集成mybatis框架 -->
      <dependency>
         <groupId>org.mybatis.spring.boot</groupId>
         <artifactId>mybatis-spring-boot-starter</artifactId>
         <version>${mybatis.spring.boot.starter.version}</version>
      </dependency>

      <!-- pagehelper 分页插件 -->
      <dependency>
         <groupId>com.github.pagehelper</groupId>
         <artifactId>pagehelper-spring-boot-starter</artifactId>
         <version>${pagehelper.spring.boot.starter.version}</version>
      </dependency>

      <!--阿里数据库连接池 -->
      <dependency>
         <groupId>com.alibaba</groupId>
         <artifactId>druid</artifactId>
         <version>${druid.version}</version>
      </dependency>

      <!--常用工具类 -->
      <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-lang3</artifactId>
      </dependency>

      <!--io常用工具类 -->
      <dependency>
         <groupId>commons-io</groupId>
         <artifactId>commons-io</artifactId>
         <version>${commons.io.version}</version>
      </dependency>

      <!--文件上传工具类 -->
      <dependency>
         <groupId>commons-fileupload</groupId>
         <artifactId>commons-fileupload</artifactId>
         <version>${commons.fileupload.version}</version>
      </dependency>

      <!--Shiro核心框架 -->
      <dependency>
         <groupId>org.apache.shiro</groupId>
         <artifactId>shiro-core</artifactId>
         <version>${shiro.version}</version>
      </dependency>

      <!-- Shiro使用Srping框架 -->
      <dependency>
         <groupId>org.apache.shiro</groupId>
         <artifactId>shiro-spring</artifactId>
         <version>${shiro.version}</version>
      </dependency>

      <!-- Shiro使用EhCache缓存框架 -->
      <dependency>
         <groupId>org.apache.shiro</groupId>
         <artifactId>shiro-ehcache</artifactId>
         <version>${shiro.version}</version>
      </dependency>

      <!-- thymeleaf模板引擎和shiro框架的整合 -->
      <dependency>
         <groupId>com.github.theborakompanioni</groupId>
         <artifactId>thymeleaf-extras-shiro</artifactId>
         <version>${thymeleaf.extras.shiro.version}</version>
      </dependency>

      <!-- 阿里JSON解析器 -->
      <dependency>
         <groupId>com.alibaba</groupId>
         <artifactId>fastjson</artifactId>
         <version>${fastjson.version}</version>
      </dependency>

      <!-- 解析客户端操作系统、浏览器等 -->
      <dependency>
         <groupId>eu.bitwalker</groupId>
         <artifactId>UserAgentUtils</artifactId>
         <version>${bitwalker.version}</version>
      </dependency>

      <!--Spring框架基本的核心工具-->
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context-support</artifactId>
      </dependency>

      <!-- 定时任务 -->
      <dependency>
         <groupId>org.quartz-scheduler</groupId>
         <artifactId>quartz</artifactId>
         <exclusions>
            <exclusion>
               <groupId>com.mchange</groupId>
               <artifactId>c3p0</artifactId>
            </exclusion>
         </exclusions>
      </dependency>

      <!--velocity代码生成使用模板 -->
      <dependency>
         <groupId>org.apache.velocity</groupId>
         <artifactId>velocity</artifactId>
         <version>${velocity.version}</version>
      </dependency>

      <!--验证码 -->
      <dependency>
         <groupId>com.github.penggle</groupId>
         <artifactId>kaptcha</artifactId>
         <version>${kaptcha.version}</version>
         <exclusions>
            <exclusion>
               <artifactId>javax.servlet-api</artifactId>
               <groupId>javax.servlet</groupId>
            </exclusion>
         </exclusions>
      </dependency>

      <!-- swagger2-->
      <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger2</artifactId>
         <version>${swagger.version}</version>
      </dependency>

      <!-- swagger2-UI-->
      <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger-ui</artifactId>
         <version>${swagger.version}</version>
      </dependency>

      <!-- HTML解析器 -->
      <dependency>
         <groupId>org.jsoup</groupId>
         <artifactId>jsoup</artifactId>
         <version>${jsoup.version}</version>
      </dependency>
      
      <!-- excel工具 -->
      <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-ooxml</artifactId>
         <version>3.9</version>
      </dependency>
      
      <!-- ftp上传文件工具,201871115:43:45 -->
      <dependency>
          <groupId>commons-net</groupId>
          <artifactId>commons-net</artifactId>
          <version>3.4</version>
      </dependency>
      <!-- 图片压缩工具类,谷歌推荐的,201871210:33:55 -->
      <dependency>
         <groupId>net.coobird</groupId>
         <artifactId>thumbnailator</artifactId>
         <version>0.4.8</version>
      </dependency>
      
      <!--gson对于json的解析 https://mvnrepository.com/artifact/com.google.code.gson/gson -->
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.8.2</version>
      </dependency>
      

   </dependencies>

   <build>
      <finalName>${project.artifactId}</finalName>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
               <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
            </configuration>
         </plugin>
      </plugins>
   </build>

   <repositories>
      <repository>
         <id>public</id>
         <name>aliyun nexus</name>
         <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
         <releases>
            <enabled>true</enabled>
         </releases>
      </repository>
   </repositories>

   <pluginRepositories>
      <pluginRepository>
         <id>public</id>
         <name>aliyun nexus</name>
         <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
         <releases>
            <enabled>true</enabled>
         </releases>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
      </pluginRepository>
   </pluginRepositories>

</project>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值