Весенняя загрузка не видит шаблон усов - PullRequest
0 голосов
/ 03 марта 2019

У меня очень простое приложение при загрузке Spring.Это всего лишь один контроллер и шаблон усов.

package io.github.aleksejshherbak.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class HomeController {
    @RequestMapping("/")
    public String index() {
        return "index";
    }
}

А шаблон просто разметка

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Person keeper</title>
</head>
<body>
    <h1>Lorem ipsum dolor sit amet.</h1>
</body>
</html>

Я установил усы с помощью gradle.Мой файл сборки

plugins {
id 'java'

    // Apply the application plugin to add support for building an application
    id 'application'


    id 'org.springframework.boot' version '2.1.0.RELEASE'
    id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}

mainClassName = 'io.github.aleksejshherbak.App'

group 'io.github'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.guava:guava:23.0'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    // https://mvnrepository.com/artifact/com.github.spullara.mustache.java/compiler
    compile group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.8.9'
}

Структура проекта на следующем рисунке enter image description here

Но когда я запускаю его и набираю в браузере localhost:8080/ У меня ошибка 404.Что случилось?

1 Ответ

0 голосов
/ 03 марта 2019

Просто добавьте в зависимость:

implementation 'org.springframework.boot:spring-boot-starter-mustache'

И настройте application.properties для усов:

spring.mustache.prefix=classpath:/templates/
spring.mustache.suffix=.mustache
...