Spring Cloud Eureka dashboard returns XML

When the eureka registration service project generated by the official website is started, the freemaker template cannot be rendered but an xml response is returned.

     1. parent  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.ycx.cloud</groupId>
    <artifactId>cloud</artifactId>
    <version>1.0</version>

    <packaging>pom</packaging>


    <!-- {@see} http://projects.spring.io/spring-cloud/ -->
    <!-- lookup parent from repository(super POM) -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
        <relativePath/>
    </parent>


    <modules>
        <module>cloud-server-center</module>
    </modules>


    <properties>
        <maven.compile.source>1.8</maven.compile.source>
        <maven.compile.target>1.8</maven.compile.target>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-cloud.version>Edgware.SR1</spring-cloud.version>
        <druid.version>1.1.6</druid.version>
        <fastjson.version>1.2.36</fastjson.version>
        <lombok.version>1.16.14</lombok.version>

        <!-- plugins version -->
        <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
        <maven-source-plugin.version>2.4</maven-source-plugin.version>
        <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
        
    </properties>


    <!-- dependencies -->
    <dependencies>
        
    </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>

            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>

            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>${druid.version}</version>
            </dependency>

            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- repository -->
    <repositories>
        <repository>
            <id>oss</id>
            <name>oss</name>
            <url>https://oss.sonatype.org/content/groups/public</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>${maven.compile.source}</source>
                        <target>${maven.compile.target}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

     2. eureka 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>

    <parent>
        <artifactId>eureka-center</artifactId>
        <groupId>com.ycx.cloud</groupId>
        <version>1.0</version>
    </parent>

    <artifactId>cloud-eureka-center</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <!--
               Spring Cloud Starter Eureka Server (deprecated,
               please use spring-cloud-starter-netflix-eureka-server)
           -->
            <!--
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
            -->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

    <!-- build -->
    <build>
        <finalName>eureka-center</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

 

     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. Run

        Use mvn spring-boot:run to run the project, test in centos6, windows10, jdk8 environment, the UI is not displayed normally, according to stackoverflow and the official source code issue can not be resolved. When excluding the dependencies of the eureka project, it is found that the freemarker-2.3.x-incubating dependency is based on the query of the maven central warehouse. There should be issues with this incubating version. The freemarker version is adjusted as follows:

<dependency>

     <groupId>org.freemarker</groupId>

    <artifactId>freemarker</artifactId>

    <version>2.3.23</version>

</dependency>

After recompiling and starting the project, the problem is solved.

 

Notes:

  • To customize the dashboard display interface, you can copy the static and templates folders in spring-cloud-netflix-eureka-server-1.xxRELEASE.jar to the src/main/resources directory in the current maven project for custom modification.
  • The service center runs for a period of time and prompts

    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.

    According to the investigation, it is related to the self-registration service.
  • The information environment under system status displays test
    Environment test
    Data center default

 

 

 

 

 

 

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326144672&siteId=291194637