Zipkin服务器提供Whitelabel错误页面 [英] Zipkin Server giving Whitelabel Error Page

查看:113
本文介绍了Zipkin服务器提供Whitelabel错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Spring Boot(v2)创建Zipkin服务器时,我面临Whitelabel错误页面.
"
白标错误页面
此应用程序没有针对/error的显式映射,因此您将其视为后备.
IST 2019年10月30日星期三11:21:35 发生意外错误(类型=未找到,状态= 404). 没有可用消息
"
而且,当我在春季启动中运行应用程序时,我得到:
找不到模板位置:classpath:/templates/(请添加一些模板或检查您的 Thymeleaf配置)"

While creating a Zipkin Server with Spring Boot(v2), I am facing Whitelabel Error Page.
"
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Oct 30 11:21:35 IST 2019 There was an unexpected error (type=Not Found, status=404). No message available
"
And also while i run the application in spring boot, i get:
" Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration) "


    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema- 
    instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
     <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>edu.rohit</groupId>
    <artifactId>ZipkinServer</artifactId>
    <version>1</version>
    <name>ZipkinServer</name>
    <description>Demo project for Spring Boot Slueth-Zipkin</description>

    <properties>
        <java.version>1.8</java.version>
        <!-- <spring-cloud.version>Hoxton.RC1</spring-cloud.version> -->
        <spring-cloud.version>2.1.3.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
        </dependency> -->

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
            <version>${spring-cloud.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
            <version>${spring-cloud.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin</artifactId>
            <version>${spring-cloud.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
      </dependencies>

     <!-- <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
      </dependencyManagement>
     -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    </project>    

application.properties

    server.port=9411
    #spring.zipkin.baseUrl= http://localhost:9411
    #server.error.whitelabel.enabled=false
    #server.error.path=/error-spring
    # spring.autoconfigure.exclude= org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
    #spring.freemarker.template-loader-path=classpath:/templates/
    #spring.freemarker.prefer-file-system-access=false
    management.security.enabled=false 

ZipkinServerApplication

    package edu.rohit.ZipkinServer;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.Bean;

    SpringBootApplication(scanBasePackages={"edu.rohit.ZipkinServer"})

     public class ZipkinServerApplication {

    /*@Bean
    public AlwaysSampler defaultSampler() {
      return new AlwaysSampler();
    }*/


     public static void main(String[] args) {
        SpringApplication.run(ZipkinServerApplication.class, args);
     }

    }   

请帮助我解决此问题

推荐答案

I did some study in actuator use in spring boot 2.x.
The actuator use have significant changes. The default endpoint root path is '/actuator' and not'/' as in 1.x. By default only two endpoint(/health, /info) is enable.

#To make all endpoints enable set
    management.endpoints.web.exposure.include=*   
#To specifically enable one endpoint(/beans) set
    management.endpoint.beans.enabled=true 
#Or we can create a WebSecurity bean like this:
    @Bean
    public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http){
          return http.authorizeExchange()
         .pathMatchers("/actuator/**").permitAll()
         .anyExchange().authenticated()
         .and().build();
    }  
#Remember in spring boot 1.x all this issues was resolved by setting the bellow but it is #depreciated in 2.x
    management.security.enabled=false
#By default the base path is '/actuator' but can be changed by setting
    management.endpoints.web.base-path= /<Mypath>

有关更多详细信息,请阅读文档 https://www. baeldung.com/spring-boot-actuators#boot-2x-actuator

For more details can read the document https://www.baeldung.com/spring-boot-actuators#boot-2x-actuator

这篇关于Zipkin服务器提供Whitelabel错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆