HV000183: Unable to initialize 'javax.el.ExpressionFactory'错误

错误原因:

在tomcat中运行没有问题,但是使用springboot 的JUnit进行单元测试时报错。这是由于在test class中添加了@value("${..}"),这需要需要添加el-api和它的实现的支持,而在tomcat中是有这两个jar包的,解决方案,在pom中添加如下依赖即可。

解决方法


        <!--参数验证-->
        <!--jsr 303-->
        <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.0.17.Final</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-el-api -->
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-el-api</artifactId>
            <version>9.0.27</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper-el -->
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jasper-el</artifactId>
            <version>9.0.27</version>
        </dependency>

标签: none

评论已关闭