[英]spring eureka - Error resolving template [eureka/status], template might not exist or might not be accessible
I am following this tutorial to implement a microservice architecture within my project. 我正在按照本教程在我的项目中实现微服务架构。
First I added the following dependencies to my project: 首先,我将以下依赖项添加到我的项目中:
</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>
After that I added a registrationServer class to the project (as described in the tutorial) and set up my config. 之后我将一个registrationServer类添加到项目中(如教程中所述)并设置我的配置。 The config of my registration server remain very basic: 我的注册服务器的配置仍然非常基本:
# 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
Now as I understood it, at this point I should be able to access http://localhost:8761 and see my setup as tracked by the registration server. 现在据我了解,此时我应该能够访问http:// localhost:8761并查看注册服务器跟踪的我的设置。 Instead I get a Whitelabel Error Page containing the following error message: 相反,我得到一个包含以下错误消息的Whitelabel错误页面 :
Error resolving template [eureka/status], template might not exist or might not be accessible by any of the configured Template Resolvers
Note: Before adding Eureka, my project consisted of a REST application which I want now to transform into a microservice. 注意:在添加Eureka之前,我的项目包含一个REST应用程序,我现在想将其转换为微服务。 The REST service contained a frontend which is organized in the project directories like this: REST服务包含一个前端,它在项目目录中组织如下:
src
- main
- resources
- templates
- index.html
- static
- built
- bundle.js
Note 2: Also I tried to disable the thymeleaf template which led to an 404 error when trying to access http://localhost:8761 . 注意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
As stated in this github issue: 正如这个github问题所述:
If your project already uses Thymeleaf as its template engine, the Freemarker templates of the Eureka server may not be loaded correctly. 如果您的项目已使用Thymeleaf作为其模板引擎,则可能无法正确加载Eureka服务器的Freemarker模板。 In this case it is necessary to configure the template loader manually: 在这种情况下,有必要手动配置模板加载器:
application.yml application.yml
spring:
freemarker:
template-loader-path: classpath:/templates/
prefer-file-system-access: false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.