【问题标题】:Spring Boot seems to be auto-generating bad pathsSpring Boot 似乎在自动生成错误路径
【发布时间】:2017-01-02 06:21:33
【问题描述】:

我正在试验 Spring Boot,并创建了一个简单的 Spring Boot webapp,应该只在 http://localhost:9200 公开一个简单/模拟主页。

这里是source code on GitHub

当我在本地运行时(说明在自述文件中),控制台输出中没有错误。但是,当我将浏览器指向 http://localhost:9200 时,系统会提示我输入 HTTP 基本身份验证样式的用户名 + 密码组合(我肯定没有自己添加),并且我永远无法真正看到主页(位于 src/main/resources/templates/web/index.html 下的那个 repo 中)。

在控制台输出中,我得到了这个堆栈跟踪:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "error", template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymeleaf-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
    at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) ~[thymeleaf-spring4-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]

谁能看出我哪里出错了?堆栈跟踪对我来说没有多大意义。

根据this answer,我的一条路径中有一个重复的正斜杠 (//),但我一辈子都看不到在哪里!

【问题讨论】:

  • 基本认证来自于安全依赖。您希望使用百里香吗?
  • 谢谢@jny (+1) - 我删除了安全依赖,基本的身份验证对话框消失了 - 感谢那里的帮助!但是,当我转到 http://localhost:9200 时,我仍然会出现空白屏幕和日志中的相同错误。

标签: spring spring-boot thymeleaf


【解决方案1】:

你的 WebController 类有一个错误的包定义 - com.surancehub.controllers,应该是 hotmeatballsoup.bootup.controllers 以便被 Boot 拾取

【讨论】:

  • 感谢@Milos!接得好!想知道为什么在编译过程中没有发现它,只是在处理模板时才抬起头来......
  • 好吧,我责怪 Groovy 的动态偷偷摸摸:D
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-11
  • 2020-03-21
  • 2014-02-02
  • 2016-08-10
  • 2016-02-15
  • 1970-01-01
相关资源
最近更新 更多