jjwt: Can't use setHeader(Header) because ambigous method call
Header is both a Header and a Map so this won’t work:
Header header = new DefaultHeader();
String payloadWithoutPartner1 = Jwts.builder()
.setClaims(claims)
.signWith(SignatureAlgorithm.HS256, key)
.setHeader(header)
.compact();
Ambiguous method call. Both setHeader (Header) in JwtBuilder and setHeader(Map<String, Object>) in JwtBuilder match
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 21 (6 by maintainers)
@lhazlewood using
Jwts.header()doesn’t change anything. Standard technique or not compiler won’t know which overload version to use, cause both are applicable. This is the simplest thing you can paste and check for yourself:Casting to map
.setHeader((Map<String, Object>) header)worksLike the last entry stated, I used
setHeaderParam, instead.I would consider using these type-safe methods a very good thing. Otherwise - why is there even a class
JwsHeader?