Spring Eureka-错误解决模板[Eureka/status],模板可能不存在或可能无法访问



我遵循本教程以在我的项目中实现微服务架构。

首先,我在项目中添加了以下依赖项:

</dependencies>
    ...
    <dependency>
        <!-- Spring Cloud starter -->
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
    </dependency>
    <dependency>
        <!-- Eureka service registration - CHANGED -->
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Finchley.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

之后,我在项目中添加了一个Incumistrationserver类(如教程中所述(并设置了我的配置。我的注册服务器的配置仍然非常基础:

# Ignore JDBC Dependency
# This demo puts 3 applicatons in the same project so they all pick up the
# JDBC Depdendency, but this application doesn't need it.
spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
# Configure this Discovery Server
eureka:
  instance:
    hostname: localhost
  client:  # Not a client, don't register with yourself
    registerWithEureka: false
    fetchRegistry: false
server:
  port: 8761  # HTTP (Tomcat) port

现在,正如我所理解的,此时,我应该能够访问http://localhost:8761,并查看注册服务器跟踪的设置。取而代之

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

注意:在添加eureka之前,我的项目由我现在想转换为微服务的REST应用程序组成。休息服务包含一个在类似项目目录中组织的前端:

src
 - main
    - resources
       - templates
          - index.html
       - static
          - built
             - bundle.js

注2:我也尝试禁用胸腺模板,该模板在尝试访问http://localhost:8761。

时导致404错误
# Discovery Server Dashboard uses FreeMarker.  Don't want Thymeleaf templates
spring:
  thymeleaf:
    enabled: false     # Disable Thymeleaf 
  datasource:
    type: org.springframework.jdbc.datasource.SimpleDriverDataSource

如本github问题所述:

如果您的项目已经使用胸腺层作为模板引擎,则可能无法正确加载Eureka服务器的Freemarker模板。在这种情况下,有必要手动配置模板加载程序:

application.yml

spring:
  freemarker:
    template-loader-path: classpath:/templates/
    prefer-file-system-access: false

最新更新