前段时间研究springboot

发现使用Application类启动的话, 可以进入Controller方法并且返回数据,但是不能跳转到WEB-INF目录下网页,

前置配置

server:
port: 8086
tomcat:
uri-encoding: UTF-8
servlet:
context-path: /
spring:
mvc:
view:
suffix: .jsp
prefix: /WEB-INF/views/
view:
suffix: .jsp
prefix: /WEB-INF/views/

使用启动类或者启动后。jar 404错误

控制台可以看见已经进入方法了

解决方案1: 使用spring-boot:run 启动

会导致问题:

打包成jar包  使用java -jar springboot.jar, 访问前端 一样会404

缺陷弥补方案  ,打包成 war包,  使用java -jar springboot.war   就OK了

解决方案2:配置pom.xml ,请看红色字体,

    <resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
<include>**/*.txt</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
</build>

<resource>
            <directory>src/main/webapp</directory>
            <targetPath>META-INF/resources</targetPath>
            <includes>
                <include>**/**</include>
            </includes>
</resource>

进行webapp目录配置后,

使用启动类启动  和 打包成jar包  都可以正常访问了

O(∩_∩)O哈哈~

修改了配置 记得 clean 一下哦

原文地址 https://blog.csdn.net/q18771811872/article/details/88051260

 

springboot 启动类启动跳转到前端网页404问题的两个解决方案的更多相关文章

  1. springBoot项目启动类启动无法访问

    springBoot项目启动类启动无法访问. 网上也查了一些资料,我这里总结.下不来虚的,也不废话. 解决办法: 1.若是maven项目,则找到右边Maven Projects --->Plug ...

  2. SpringBoot测试类启动错误 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

    报错 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Cont ...

  3. 【spring boot】启动类启动 错误: 找不到或无法加载主类 com.codingapi.tm.TxManagerApplication 的解决方案

    导入的一个外部的spring boot项目,运行启动类,出现错误:找不到或无法加载主类 com.codingapi.tm.TxManagerApplication 解决方案: 将所有错误处理完成后,再 ...

  4. SpringBoot无法书写主启动类的情况之一

    首先需要引入 spring-boot-starter-web 依赖[springboot web 项目 启动器 jar包]: 如果使用镜像请确保镜像路径正确,可参看笔者博客园m-yb的maven 安装 ...

  5. SpringBoot源码分析之---SpringBoot项目启动类SpringApplication浅析

    源码版本说明 本文源码采用版本为SpringBoot 2.1.0BUILD,对应的SpringFramework 5.1.0.RC1 注意:本文只是从整体上梳理流程,不做具体深入分析 SpringBo ...

  6. springboot 单元测试 指定启动类

    问题 在做单元测试时,写了一个工具类,用于注入spring的上下文. public class AppBeanUtil implements ApplicationContextAware { pri ...

  7. springboot系列(三) 启动类中关键注解作用解析

    一.Springboot:请求入口 @SpringBootApplication @EnableAspectJAutoProxy @EnableScheduling @EnableTransactio ...

  8. 【杂谈】SpringBoot为啥不用配置启动类

    前言 在学习SparkJava.Vert.x等轻量级Web框架的时候,都遇到过打包问题,这两个框架打包的时候都需要添加额外的Maven配置,并指定启动类才能得到可执行的JAR包: 而springboo ...

  9. 震惊!你还不知道SpringBoot真正的启动引导类

    引言 SpringBoot项目中的启动类,一般都是XXApplication,例如「StatsApplication」,「UnionApplication」. 每个项目的启动类名称都不一样.但是它的启 ...

随机推荐

  1. LightOj:1422-Halloween Costumes

    传送门:http://www.lightoj.com/volume_showproblem.php?problem=1422 Halloween Costumes problem descriptio ...

  2. poj 2229 拆数问题 dp算法

    题意:一个n可以拆成 2的幂的和有多少种 思路:先看实例 1   1 2    1+1     2 3     1+1+1  1+2 4      1+1+1+1  1+1+2  2+2  4 5  ...

  3. ADT操作实例

    ps.1.put(rank,value) 把当前rank的元素的数值修改 2.get(rank)获取rank的元素 3.remove(value)把向量中value剔除掉 4.size()返回元素个数 ...

  4. 【原创】关于高版本poi autoSizeColumn方法异常的情况

    之前使用的3.9版本,autoSizeColumn方法一切正常,现在切换到了3.15版本这个方法就出先了问题,问题如下,无法自动追踪所有的列. Exception in thread "ma ...

  5. PHP 开启或关闭错误提示

    如果不具备修改 php.ini 的权限,可以如下: // 只需在php文件中加入这两句即可开启PHP错误提示 ini_set("display_errors", "On& ...

  6. 浅析 Node.js 的 vm 模块以及运行不信任代码

    在一些系统中,我们希望给用户提供插入自定义逻辑的能力,除了 RPC 和 REST 之外,运行客户提供的代码也是比较常用的方法,好处是可以极大地减少在网络上的耗时.JavaScript 是一种非常流行而 ...

  7. Codeforces Round #459 (Div. 2)

    A. Eleven time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

  8. TOJ2680: 最大矩阵连乘次数

    2680: 最大矩阵连乘次数  Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 144 ...

  9. Ruby 符号【转】

    Ruby的符号足以让很多初学者迷惑上一段时间,看过本章节后,或许会解开你心中的疑惑. 在Ruby中,一个符号是就是一个Symbol类的实例,它的语法是在通常的变量名前加一个冒号,如 :my_sy Ru ...

  10. [译]pandas中的iloc loc的区别?

    loc 从特定的 gets rows (or columns) with particular labels from the index. iloc gets rows (or columns) a ...