javaspring-bootmavenjjwt

How Can I Fix "'setSigningKey(java. security. Key)' is deprecated "


I Java Spring Boot App, I Just Update Maven Libraries: (jjwt-api (0.12.6)) from (jjwt-api (0.11.0))

And This My Old Code For Claims:

import io.jsonwebtoken.Jwts;

Claims claims = Jwts
    .parserBuilder()                // Initializes JWT Parser Builder
    .setSigningKey(encryptionKey()) // Sets The Encryption Key For Parsing
    .build()                        // Builds The JWT Parser
    .parseClaimsJws(token)          // Parses The Token To Retrieve Claims
    .getBody();                     // Retrieves The Claims Body

First Error "Cannot resolve method 'parserBuilder' in 'Jwts'"; If Fix It By Replace parserBuilder() With parser()

After Changed It's Show Notifications:

How Can I Fix This?


Solution

  • The new syntax would be:

    Jwts.parser()
        .verifyWith(encryptionKey())
        .build()
        .parseSignedClaims(jwt)
        .getPayload();