【问题标题】:Basic "Hello World" Spring Boot application in IDEA doesn't workIDEA 中的基本“Hello World”Spring Boot 应用程序不起作用
【发布时间】:2020-03-15 06:16:52
【问题描述】:

我无法确定 spring.io 教程中的说明是否有问题,或者 IDEA 是否有问题。一些帮助会很好。

我在 spring.io 上关注 guide 来创建一个简单的博客应用程序。我已使用 spring initializr 按指示创建应用程序(使用 Gradle、JDK 1.8、Kotlin),但我无法从 Spring Boot 运行/调试配置运行应用程序。它仅在我运行 gradle "bootRun" 任务时才有效,但通过 IntelliJ 运行会产生一个 Whitelabel 错误页面。

This application has no explicit mapping for /error, so you are seeing this as a fallback.

此外,我控制台中的 Spring Boot 输出显示 MustacheAutoConfiguration 类在我的类路径中找不到 /templates/ 文件夹。

2019-11-19 13:06:07.136  WARN 11840 --- [  restartedMain] o.s.b.a.m.MustacheAutoConfiguration      : Cannot find template location: classpath:/templates/ (please add some templates, check your Mustache configuration, or set spring.mustache.check-template-location=false)

我的 BlogApplication 的 Spring Boot 运行/调试配置有“使用模块的类路径:blog.main”。

我这里还有什么遗漏的吗?

【问题讨论】:

  • 您是否创建了模板文件夹?里面有你的模板吗?
  • 是的。正如我所提到的,当我通过 gradle 使用它时它可以工作。所以至少所有必需的部分都在那里。

标签: spring-boot intellij-idea


【解决方案1】:

从 github 源克隆后运行应用程序。它从 intellj 想法运行得很好。在 JDK 13、11 和 8 上测试

并且从 intellj idea 的 Boot run 配置如下。

所以我建议检查你的 intelljidea 的 gradle 配置。

【讨论】:

  • 我创建项目时,自动生成的 .idea 项目文件夹似乎有问题。如果我删除文件夹并重新导入 gradle 项目,它就可以工作。当我有更多时间时,我需要弄清楚到底有什么区别。
  • 这显然是一个已知问题。 youtrack.jetbrains.com/issue/IDEA-221673
【解决方案2】:

目前这似乎是一个已知问题。见:https://youtrack.jetbrains.com/issue/IDEA-221673

【讨论】:

    猜你喜欢
    • 2014-10-31
    • 2018-02-02
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多