Is there a way to use both auth0-spring-security-api and java-jwt in the same project?

Marco De Simone :

I'm trying to use auth0 and JWT in my Spring Boot project. I have imported these dependencies:

<dependency>
    <groupId>com.auth0</groupId>
    <artifactId>auth0-spring-security-api</artifactId>
    <version>1.2.1</version>
</dependency>
<dependency>
    <groupId>com.auth0</groupId>
    <artifactId>java-jwt</artifactId>
    <version>3.8.1</version>
</dependency>

I also use JwtWebSecurityConfigurer to configure spring security.

If I use only auth0-spring-security-api, JwtWebSecurityConfigurer works correctly and checks my token. But I can't use the JWT class that is contained in java-jwt artifact. If i import both dipendencies in pom, it stops working and when Spring security checks my token, it says java.lang.NoSuchMethodError: com.auth0.jwt.interfaces.Verification.withIssuer(Ljava/lang/String;)Lcom/auth0/jwt/interfaces/Verification;

Also, I know that java-jwt library is a dependency of auth0-spring-security-api, I think that there's a sort of collision with two libraries. Does anyone have a solution? Thanks

Marco De Simone :

Solved! If anyone has this problem, the solution is: Check your pom.xml and the pom of auth0-spring-security-api. The java-jwt dependency imported from auth0-spring-security-api must be the same of java-jwt in your pom.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=123519&siteId=1