Spring Cloud Eureka dashboard returns XML

阅读更多

使用官网生成的eureka注册服务项目启动时无法渲染freemaker模板而是返回xml响应。

     1. parent  pom.xml

 



    4.0.0

    com.ycx.cloud
    cloud
    1.0

    pom


    
    
    
        org.springframework.boot
        spring-boot-starter-parent
        1.5.10.RELEASE
        
    


    
        cloud-server-center
    


    
        1.8
        1.8
        1.8
        UTF-8
        UTF-8
        Edgware.SR1
        1.1.6
        1.2.36
        1.16.14

        
        3.5.1
        2.4
        2.8.2
        
    


    
    
        
    


    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            

            
                com.alibaba
                fastjson
                ${fastjson.version}
            

            
                com.alibaba
                druid
                ${druid.version}
            

            
                org.projectlombok
                lombok
                ${lombok.version}
                provided
            
        
    

    
    
        
            oss
            oss
            https://oss.sonatype.org/content/groups/public
            
                true
            
        

        
            spring-milestones
            Spring Milestones
            https://repo.spring.io/libs-milestone
            
                false
            
        
    

    
        
            
                
                    org.apache.maven.plugins
                    maven-compiler-plugin
                    ${maven-compiler-plugin.version}
                    
                        ${maven.compile.source}
                        ${maven.compile.target}
                        ${project.build.sourceEncoding}
                    
                
                
                    org.apache.maven.plugins
                    maven-source-plugin
                    ${maven-source-plugin.version}
                    
                        
                            attach-sources
                            
                                jar-no-fork
                            
                        
                    
                
                
                    org.apache.maven.plugins
                    maven-deploy-plugin
                    ${maven-deploy-plugin.version}
                
            
        
    

     2. eureka pom.xml

 




    4.0.0

    
        eureka-center
        com.ycx.cloud
        1.0
    

    cloud-eureka-center

    
        
            org.springframework.cloud
            spring-cloud-starter-config
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-server
            
            
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        
    

    
    
        eureka-center
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

 

     3. application.yml

 

spring:
    application:
        name: cloud-server-center
    freemarker:
        prefer-file-system-access: false
    thymeleaf:
        enabled: false

server:
    port: 8088

eureka:
    instance:
        hostname: localhost
        instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
    client:
        registerWithEureka: false  #false: dont't register to server center as a client
        fetchRegistry: false       #true throws Cannot execute request on any known server
        waitTimeInMsWhenSyncEmpty: 0
        #serviceUrl:
        #    defaultZone: http://localhost:${server.port}/eureka
    #dashboard:
    #    path: /

# Full authentication is required to access actuator endpoints. 
# Consider adding Spring Security or set 'management.security.enabled' to false.
management:
    security:
        enabled: false

 

 

     4.运行

        使用 mvn spring-boot:run 运行工程,在centos6,windows10,jdk8环境下测试,UI均不正常显示,根据stackoverflow和官方源代码的issue均不能解决。排除eureka项目的依赖时发现,freemarker-2.3.x-incubating依赖,根据maven中心仓库查询情况。这个孵化版本应该存在问题。freemarker版本调整如下:

     org.freemarker

    freemarker

    2.3.23

重新编译后启动项目,问题解决。

 

附注:

  • 自定义dashboard显示界面,可以将spring-cloud-netflix-eureka-server-1.x.x.RELEASE.jar中static和templates文件夹拷贝至当前maven工程中的src/main/resources目录下进行自定义修改。
  • 服务中心运行一段时间提示

    EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

    据查和自注册服务相关。
  • system status下信息环境显示test
    Environment test
    Data center default

 

 

 

 

 

 

附:https://stackoverflow.com/questions/43314822/spring-eureka-dashboard-returns-xml-on-wildfly

你可能感兴趣的:(Spring Cloud Eureka dashboard returns XML)