【问题标题】:Spring eureka dashboard returns XML on wildflySpring eureka 仪表板在 Wildfly 上返回 XML
【发布时间】:2017-09-05 00:06:40
【问题描述】:

我正在尝试在 wildfly 部署我的 eureka 服务,但是当我尝试访问仪表板时,我得到以下 xml 作为响应:

<com.netflix.eureka.util.StatusInfo>
<generalStats>
<environment>test</environment>
<num-of-cpus>4</num-of-cpus>
<total-avail-memory>3525mb</total-avail-memory>
<current-memory-usage>736mb (20%)</current-memory-usage>
<server-uptime>00:01</server-uptime>
</generalStats>
<applicationStats>
<registered-replicas>http://localhost:8761/eureka/</registered-replicas>
<available-replicas/>
<unavailable-replicas>http://localhost:8761/eureka/,</unavailable-replicas>
</applicationStats>
<instanceInfo>
<instanceId>note:eureka-service:8761</instanceId>
<hostName>note</hostName>
<app>EUREKA-SERVICE</app>
<ipAddr>192.168.1.36</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">8761</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>0</registrationTimestamp>
<lastRenewalTimestamp>0</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>0</serviceUpTimestamp>
</leaseInfo>
<metadata class="java.util.Collections$EmptyMap"/>
<homePageUrl>http://note:8761/</homePageUrl>
<statusPageUrl>http://note:8761/info</statusPageUrl>
<healthCheckUrl>http://note:8761/health</healthCheckUrl>
<vipAddress>eureka-service</vipAddress>
<secureVipAddress>eureka-service</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1491796603178</lastUpdatedTimestamp>
<lastDirtyTimestamp>1491796615476</lastDirtyTimestamp>
</instanceInfo>
</com.netflix.eureka.util.StatusInfo>

有人知道如何在 wildfly 部署仪表板吗?

【问题讨论】:

    标签: java spring-boot wildfly netflix-eureka


    【解决方案1】:

    就我而言,其他两种解决方案没有帮助。

    我搜索了几个小时,并在调试 spring 代码时找到了解决方案。 freemarker 的 viewResolver 没有在 spring-cloud-netflix-eureka-server-1.3.1.RELEASE.jar 中找到模板。

    事实上,我只需要设置一个简单的属性就可以完成任务:

    spring.freemarker.prefer-file-system-access=false

    【讨论】:

    • 我放了这个属性,但它不能再工作了,并且想出了 xml ui
    • 这个属性适用于我的 Spring Boot 版本 2.0.4.RELEASE。它就像魅力一样。你是怎么知道这个@Benjamin Schüller 的?
    • 以防万一有人需要澄清:此解决方案有效,因为默认情况下,eureka 在类路径的 templates 文件夹中搜索模板(创建仪表板页面)。因为,在应用程序服务器上,可能有多个 jars 具有该文件夹(并且它们不包含 Eureka 正在搜索的模板),因此会引发错误。上面的方案保证了Eureka不会在其他jar中搜索templates文件夹,而只搜索自己的jar
    【解决方案2】:

    对我来说,问题是我有一个空文件夹,src/main/resources/templates。当此文件夹存在时,FreeMarkerView 看不到 spring-cloud-netflix-eureka-server 中包含的嵌入模板。我不记得这个文件夹的来源,但我怀疑它在在线示例中。删除它更正了问题。

    【讨论】:

      【解决方案3】:

      我在使用以下 pom.xml 时遇到了同样的问题:

      <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
      
      <groupId>com.example</groupId>
      <artifactId>eureka</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>
      
      <name>eureka</name>
      <description>Demo project for Spring Boot</description>
      
      <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>1.5.3.RELEASE</version>
          <relativePath/> <!-- lookup parent from repository -->
      </parent>
      
      <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
          <java.version>1.8</java.version>
          <spring-cloud.version>Dalston.RELEASE</spring-cloud.version>
      </properties>
      
      <dependencies>
          <dependency>
              <groupId>org.springframework.cloud</groupId>
              <artifactId>spring-cloud-starter-eureka-server</artifactId>
          </dependency>
      
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-test</artifactId>
              <scope>test</scope>
          </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>
      

      这是自动生成的https://start.spring.io/ 页面的 pom.xml。事实证明,我必须将 spring-boot-starter-parent 工件的版本号更改为较低版本,才能正确显示 eureka 仪表板。

      <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>1.5.2.RELEASE</version>
          <relativePath/> <!-- lookup parent from repository -->
      </parent>
      

      【讨论】:

        【解决方案4】:

        我最近遇到了这个问题。最后发现是freemarker jar坏了,我把freemarker jar从本地maven repos中删除,重新下载,就解决了。

        【讨论】:

          猜你喜欢
          • 2018-10-02
          • 1970-01-01
          • 2020-05-21
          • 2019-03-25
          • 1970-01-01
          • 1970-01-01
          • 2019-04-23
          • 2019-01-31
          • 1970-01-01
          相关资源
          最近更新 更多