简体   繁体   English

javax.validation.ValidationException:HV000183:使用WebTestClient时无法初始化'javax.el.E​​xpressionFactory'

[英]javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory' when using WebTestClient

I am trying to write an integration test with WebTestClient that will only standup the controller I'm testing with a WebTestClient to make the requests. 我正在尝试使用WebTestClient编写集成测试,该测试只能使我正在使用WebTestClient测试的控制器站起来以发出请求。 On starting a test, I get this in the console: 在开始测试时,我在控制台中得到了这个:

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

I can start the app as normal and everything works fine. 我可以正常启动该应用,并且一切正常。 Here's my test setup: 这是我的测试设置:

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()
        }
    }

And here are my gradle.build dependencies: 这是我的gradle.build依赖项:

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}"
}

Any help would be greatly appreciated! 任何帮助将不胜感激!

Turns out I needed to have a javax.el added to classpath. 原来我需要将javax.el添加到classpath中。 Spring includes javax.el-api, but not an el. Spring包含javax.el-api,但不包含el。 Added compile "org.glassfish:javax.el:3.0.0" and it worked. 添加了compile "org.glassfish:javax.el:3.0.0" ,它可以正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HV000183:无法初始化&#39;javax.el.E​​xpressionFactory&#39; - HV000183: Unable to initialize 'javax.el.ExpressionFactory' 无法在反应式测试中初始化“javax.el.E​​xpressionFactory” - Unable to initialize 'javax.el.ExpressionFactory' in reactive testing javax.validation.ValidationException: HV000064: 无法实例化 ConstraintValidator - javax.validation.ValidationException: HV000064: Unable to instantiate ConstraintValidator 如何解决 javax.validation.ValidationException: HV000064: Unable to instanceiate ConstraintValidator: in Spring - How do get around a javax.validation.ValidationException: HV000064: Unable to instantiate ConstraintValidator: in Spring javax.validation.ValidationException: HV000028: 在测试中 isValid 期间出现意外异常 - javax.validation.ValidationException: HV000028: Unexpected exception during isValid in Test 在IntelliJ中运行Spring Boot导致无法加载'javax.el.E​​xpressionFactory' - Running Spring Boot within IntelliJ results in Unable to load 'javax.el.ExpressionFactory' 在Google App Engine标准版上运行Spring Boot Application时发生javax.el.E​​xpressionFactory错误 - javax.el.ExpressionFactory Error when running Spring Boot Application on Google App Engine Standard 从 SpringBoot 2.6.6 升级到 2.6.7 更改了验证行为 ( javax.validation.ConstraintDeclarationException: HV000151 ) - Upgrading from SpringBoot 2.6.6 to 2.6.7 changed behaviour with validation ( javax.validation.ConstraintDeclarationException: HV000151 ) spring Conveter 的 Javax 验证 - Javax validation for spring Conveter 仅当不是 null 时,如何使用 javax 验证对字段应用自定义验证? - How to apply custom validation on a field using javax validation only if it is not null?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM