Javax.validation.ValidationException:HV000183:使用WebTestClient时无法初始化javax.el.ExpressionFactory [英] javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory' when using WebTestClient

查看:4
本文介绍了Javax.validation.ValidationException:HV000183:使用WebTestClient时无法初始化javax.el.ExpressionFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个与WebTestClient的集成测试,该测试将仅支持我正在使用WebTestClient测试的控制器发出请求。在开始测试时,我在控制台中得到以下信息:

14:33:50.435 [main] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.0.9.Final
14:33:50.442 [main] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
14:33:50.457 [main] DEBUG org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean - Failed to set up a Bean Validation provider
javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead

我可以正常启动应用程序,一切正常。以下是我的测试设置:

import org.springframework.http.MediaType
import org.springframework.test.web.reactive.server.WebTestClient
import reactor.core.publisher.Flux
import spock.lang.Specification
import spock.lang.Subject

class LocationControllerSpec extends Specification {

        @Subject
        private LocationController controller

        private LocationService service

        private WebTestClient testClient

        def setup() {
            service = Mock(LocationService)
            controller = new LocationController(service)

            testClient = WebTestClient.bindToController(controller).build()
        }

        def 'should work'() {

            Flux<List<Foo>> serviceResponse = Flux.just([bar])

            given: 'We expect the service to respond with a Location'
            service.getThing(a, b, c) >> serviceResponse

            expect: 'we should get a bar back'
            testClient.get().uri('/bar)
                        .accept(MediaType.APPLICATION_JSON_UTF8)
                        .exchange()
                        .expectStatus().isOk()
        }
    }

以下是我的级别。构建依赖项:

ext {
    javaVersion = '1.8'
    springIoVersion = 'Cairo-RELEASE'

    // Dependency versions NOT in Spring IO Platform
    dseJavaDriverVersion = '1.5.1'
    resilience4jVersion = '0.12.0'
    spockVersion = '1.1-groovy-2.4'
    cglibVersion = '3.2.0'
    cassandraUnitVersion = '3.3.0.2'
}

dependencies {
    compile "com.datastax.dse:dse-java-driver-core:${dseJavaDriverVersion}"
    compile "com.fasterxml.jackson.module:jackson-module-kotlin"
    compile "io.github.resilience4j:resilience4j-all:${resilience4jVersion}"
    compile "io.github.resilience4j:resilience4j-reactor:${resilience4jVersion}"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    compile "org.jetbrains.kotlin:kotlin-reflect"
    compile 'org.springframework.boot:spring-boot-starter-data-cassandra-reactive'
    compile 'org.springframework.boot:spring-boot-starter-webflux'

    runtime 'org.springframework.boot:spring-boot-devtools'

    testCompile 'org.springframework.boot:spring-boot-starter-test'
    testCompile 'io.projectreactor:reactor-test'
    testCompile "org.spockframework:spock-core:${spockVersion}"
    testCompile "org.spockframework:spock-spring:${spockVersion}"
    testCompile "cglib:cglib-nodep:${cglibVersion}"

    integrationTestsCompile "org.cassandraunit:cassandra-unit-spring:${cassandraUnitVersion}"
}

如有任何帮助,不胜感激!

推荐答案

原来我需要在类路径中添加一个javax.el。Spring包含了javax.el-api,但不包含el。添加了compile "org.glassfish:javax.el:3.0.0",它起作用了。

这篇关于Javax.validation.ValidationException:HV000183:使用WebTestClient时无法初始化javax.el.ExpressionFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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