Record a jar package conflict

Prepare to add data verification in the workflow project, and then import the jar package

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.3.1.Final</version> 
</dependency>

Join an entity
Add a control layer
But when the annotation @ NotBlank is written on an attribute of an entity, it turns red. What's the matter? I don't care. I'll try another regular. It's red again. What's going on? Find out the reasons on the Internet, saying that the version is incompatible, saying that the spring boot version is too high, but I can't change the spring boot version, so continue to look at other reasons, and then look at my spring boot version 2.3.1, so I suddenly see a blog saying that the spring boot has been compatible with the validator since 2.3x, so delete the previous left and import the new package again

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

nice ~ every verification annotation can be used, and it's not red. It's very vain. Try writing an interface for the control layer first

@RestController
public class CheckTestController {
    @PostMapping("/check")
    public CheckTest check(@RequestBody @Valid CheckTest checkTest) {
        return checkTest;
    }

}

Yes, no ERROR is reported. There is only one step to success. ctrl+shift+f10, start! Initialization data... When loading workflow data, you can only see the code scrolling page by page... Say it sooner or later, suddenly! A red word came into sight – ERROR, WDNMD!

What's the reason?
Errors are reported as follows:

ERROR 9944 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    javax.el.ELManager.getExpressionFactory(ELManager.java:38)

The following method did not exist:

    javax.el.ELUtil.getExpressionFactory()Ljavax/el/ExpressionFactory;

The method's class, javax.el.ELUtil, is available from the following locations:

    jar:file:/C:/Users/CC/.m2/repository/javax/el/el-api/2.2/el-api-2.2.jar!/javax/el/ELUtil.class
    jar:file:/C:/Users/CC/.m2/repository/org/glassfish/jakarta.el/3.0.3/jakarta.el-3.0.3.jar!/javax/el/ELUtil.class

The class hierarchy was loaded from the following locations:

    javax.el.ELUtil: file:/C:/Users/CC/.m2/repository/javax/el/el-api/2.2/el-api-2.2.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.el.ELUtil

????? What is this? This is a jar package conflict. el-api.jar is just a jar package dependency of an expression. However, geese, I don't think it has been introduced into maven

jar package conflict. There are already B in A, and you introduce B again, resulting in conflict, or you introduce two A separately

The solution is to find two conflicting packages and delete the lower version, because the higher version is generally downward compatible. If the higher version is not available, replace it with the lower version

I checked step by step here and found that a package el-api-2.2.jar had been introduced into the workflow
and

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
</dependency>   

The package of el is also introduced in. Therefore, after trade-offs, I deleted the spring boot starter validation dependency and re imported a separate verification dependency (it should be noted that the version of the dependency is compatible with spring boot 2.3x) ↓

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.4.0.Final</version>
        </dependency>

This dependency is only a simple verification dependency, so there will be no conflict in el.jar

Summary: at first, the validator version was too low and incompatible with spring boot 2.3. X. then, the template of spring boot validator was imported, because the template and workflow depended on different versions of el.jar respectively, resulting in jar package conflict. Finally, I deleted the template of spring boot validator, solved the el.jar conflict, and introduced a higher version of validator compatible with spring boot 2.3x, The project runs successfully ~ ~~

Tags: Java Maven Activiti

Posted on Tue, 23 Nov 2021 08:04:37 -0500 by moonie