当前位置: 首页 > news >正文

南联企业网站建设/磁力搜索引擎

南联企业网站建设,磁力搜索引擎,蝶恋直播免费视频观看,碳晶板全屋装修的利和弊目录一、异常错误二、原因三、解决方法方法1. 将无法编译的静态资源放入可编译目录下方法2. 重新编译项目加载资源方法3. 修改pom.xml资源配置文件方法4. 不连接远程数据库启动,使用本地数据库一、异常错误 Springboot使用thymeleaf,并连接远程数据库启…

目录

  • 一、异常错误
  • 二、原因
  • 三、解决方法
    • 方法1. 将无法编译的静态资源放入可编译目录下
    • 方法2. 重新编译项目加载资源
    • 方法3. 修改pom.xml资源配置文件
    • 方法4. 不连接远程数据库启动,使用本地数据库

一、异常错误

Springboot使用thymeleaf,并连接远程数据库启动时,无法加载resources中的静态资源

浏览器报错

Failed to load resource: the server responded with a status of 404 ()

在这里插入图片描述

后端启动时报错

Servlet.service() for servlet [dispatcherServlet] in context with path [/ce] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template 

在这里插入图片描述
前端打开页面时后端报错

Exception processing template "/web/studyOutline/studyOutline": Error resolving template [/web/studyOutline/studyOutline], template might not exist or might not be accessible by any of the configured Template Resolvers

在这里插入图片描述

二、原因

打包编译项目,显示找不到js、css、html等静态资源,但本地路径并没有写错,于是我去找编译文件,查看是不是静态资源没有编译到,打开项目下的target文件夹

在这里插入图片描述
前往classes文件夹,发现项目resources下对应的templates韦文件夹没有编译到,缺少静态资源,当然会报错了

在这里插入图片描述
在这里插入图片描述

三、解决方法

方法1. 将无法编译的静态资源放入可编译目录下

既然服务器不能编译templates文件夹,那么把templates文件夹放入calsses路径下即可,这样处理就能获取templats下的静态资源了,但如果静态资源有改动,需要手动放入classes文件夹下,再次启动项目即可读取资源

在这里插入图片描述
如果再次启动项目,还是显示找不到js、css、html等静态资源,请看方法2

方法2. 重新编译项目加载资源

由于服务器编译拦截了静态资源,导致出现异常,需要重新打包编译

打开IDEA带的Maven管理,双击clean清除由项目编译创建的target

再双击install安装jar包到本地仓库
在这里插入图片描述

项目打包出现异常

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.

在这里插入图片描述

系统默认编码是GBK,maven提升需要使用UTF-8,在setting中修改项目编码为UTF-8

在这里插入图片描述

在这里插入图片描述

出现 Failed to execute goal是由于测试用例有问题,

 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-test) on project springboot_04_profile: Input length = 1 -> [Help 1]

在这里插入图片描述

选择跳过测试用例

在这里插入图片描述

再次双击install,编译成功,启动项目即可读取静态资源

在这里插入图片描述
如果设置编码还是打包失败,或者显示找不到js、css、html等静态资源,请看方法3

方法3. 修改pom.xml资源配置文件

如果设置编码还是打包失败,或者显示找不到js、css、html等静态资源,说明服务器没有访问资源的权限,需要在pom.xml的build下引入资源文件

<!--           引入静态资源文件   --><resources><resource><directory>src/main/resources</directory><includes><include>**/*.css</include><include>**/*.js</include><include>**/*.html</include><include>**/*.png</include><include>**/*.properties</include><include>**/*.yml</include><include>**/*.xml</include><include>**/*.conf</include></includes></resource></resources>

再次insall,显示打包成功,浏览器404的问题也解决了,加载了静态资源

在这里插入图片描述

方法4. 不连接远程数据库启动,使用本地数据库

开头说了,Springboot使用thymeleaf,并连接远程数据库启动时,无法加载resources中的静态资源,这是一个大坑,如果不连接远程数据库启动,则不存在服务器访问资源的问题

打开application.properties配置文件,注释掉连接远程数据库的代码,改用本地数据库,就不会有访问资源的问题了,可以直接加载,浏览器不再出现Failed to load resource问题

在这里插入图片描述

异常索引

  • Failed to load resource: the server responded with a status of 404 ()
  • Servlet.service() for servlet [dispatcherServlet] in context with path [/ce] threw exception [Request processing failed; nested
    exception is org.thymeleaf.exceptions.TemplateInputException: Error
    resolving template
  • Exception processing template “/web/studyOutline/studyOutline”: Error resolving template [/web/studyOutline/studyOutline], template
    might not exist or might not be accessible by any of the configured
    Template Resolvers
  • [INFO] Using ‘UTF-8’ encoding to copy filtered resources. [INFO] Using ‘UTF-8’ encoding to copy filtered properties files.
  • Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
    (default-test) on project springboot_04_profile: Input length = 1 ->
    [Help 1]
http://www.jmfq.cn/news/4833667.html

相关文章:

  • 洛阳做网站的公司/互联网营销软件
  • 如何创建网站难吗/免费建网站软件下载
  • 响应式网站建设费用/广告免费发布信息平台
  • 购物网站开发毕业论文/郴州网站建设推广公司
  • 雅昌网站做古董交易/制作企业网站的公司
  • 做购物网站收费标准/品牌推广方案案例
  • 关于政府网站建设请示卡/郑州网站seo
  • wordpress后台网址/清远网站seo
  • 网站建设流/百度网页版 入口
  • 蒙牛官网网站怎么做的/阿里指数查询官网
  • 网上做兼职正规网站/廊坊百度关键词优化怎么做
  • 深圳b2b2c网站建设/免费友情链接网页
  • 网站正在建设中的代码/app推广好做吗
  • 广州制作网站公司/试分析网站推广和优化的原因
  • wordpress建2个网站吗/无锡seo公司哪家好
  • 域名注册 网站建设 好做吗/网站更换服务器对seo的影响
  • 做网站用什么工具/网站top排行榜
  • linux系统搭建网站/游戏推广赚钱
  • 一区适合晚上一个人看b站/网站推广计划方案
  • 企业网站建设存在的不足/sem推广外包
  • 天津外贸公司网站制作/seo快速提升排名
  • 做一名优秀网站设计师计划/seo搜索引擎优化技术教程
  • 珠海网站开发/网站查询ip
  • 登记注册身份验证app下载/网站seo视频狼雨seo教程
  • 网站做博彩客服怎么样/怎么做网页设计的页面
  • 国家企业信用信息公示官网糸 /株洲seo优化首选
  • 乌克兰网站后缀/上海网站建设联系方式
  • 天津网站制作/关键词优化流程
  • 编程软件做网站的/百度提交入口网址是什么
  • 上海市企业服务云网站/百度之家