首页 > 解决方案 > 如果从 IntelliJ IDEA 运行,则找不到 Spring Boot 模板

问题描述

我刚刚使用 Intellij IDEA Ultimate 2019.2.3 创建了一个新的 Spring Boot(2.1.8) Gradle 项目,该项目具有基于 Java 12 的 Thymeleaf 支持。

如果我创建一个引导 jar 文件并从命令行执行该 jar,那么该应用程序可以正常工作。所以代码/模板和目录应该没问题。

但是,如果我从 IDE 模板运行应用程序,则解析不起作用。我得到了“通常”的错误:

Error resolving template [auth/login], template might not exist or might not be accessible by any of the configured Template Resolvers

我的旧项目运行良好。该问题仅存在于 IDEA 2019.2.3 生成的项目中

自动生成的 gradle 文件如下所示:

plugins {
    id 'org.springframework.boot' version '2.1.8.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

我试图弄清楚它是否是 IDE 设置的结果或生成的 gradle 构建脚本或其他问题的结果。

标签: spring-bootgradleintellij-ideathymeleaf

解决方案


推荐阅读