首页 > 解决方案 > NoSuchFieldError:DEFAULT_INCOMPATIBLE_IMPROVEMENTS

问题描述

在 Spring boot 2.3.3 上试用 Netflix hystrix 时出现以下错误 - ...

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'freeMarkerConfigurer' defined in org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: DEFAULT_INCOMPATIBLE_IMPROVEMENTS

主要 SimpleClientApplication.java 具有以下注释

@SpringBootApplication
@EnableCircuitBreaker
@EnableHystrixDashboard

产品列表控制器.java ...

@RestController
@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class })
public class ProductListController {

    @GetMapping
    @HystrixCommand(fallbackMethod = "defaultProducts")
    public List<String> cloudProductList() {

        RestTemplate restTemplate = new RestTemplate();
        URI uri = URI.create("http://localhost:8090/products");

        return restTemplate.getForObject(uri, List.class);
    }

    public List<String> defaultProducts() {
        return Arrays.asList("Spring Cloud");
    }
}

pom.xml ...

4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.3.RELEASE com.demo simple-client-application 1.0 simple-client-application Spring Boot 演示项目

    <properties>
        <java.version>14</java.version>
        <spring-cloud.version>Hoxton.SR8</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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.9</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>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-hystrix</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.9</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.9.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>2.3.3.RELEASE</version>
        </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>

</project>

标签: javaspring-bootspring-cloud-netflix

解决方案


推荐阅读