This is my example code:
private String createToken(Map<String,Object> claims, String subject) {
return Jwts.builder()
.setClaims(claims)
.setSubject(subject)
.setIssuedAt(new Date(System.currentTimeMillis()))
//the token will be expired in 10 hours
.setExpiration(new Date(System.currentTimeMillis() + 1000* 60 * 60 *10))
.signWith(SignatureAlgorithm.HS256, secret).compact();
}
setClaims setSubject setIssuedAt setExpiration signWith are all deprecated
I need to use JWT in API, and the IDE tells me that the .signXXX method are deprecated, maybe it's because my dependency version is latest, my version is 0.12.5
Just remove the
setfrom every method. and for thesignWith()method, modify it the way I did note: see the picture below.enter image description here