maven
<!-- JWT -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.8.3</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
1.登入生成token
try {
// 帐号密码认证成功后生成令牌
Date expire_date = new Date(System.currentTimeMillis() + 3600000);//过期时间
String token = Jwts.builder().setSubject(params.get("用户账号").toString())// 账户信息
.setIssuedAt(new Date())// 生成时间
.setExpiration(expire_date)
.setId()// 用户信息
.signWith(SignatureAlgorithm.HS256, KEY)// 加密方式和密钥(KEY自定义)
.compact();
Map<String, Object> result = new HashMap<String, Object>();
// 响应客户端数据,token
result.put("status", "success");
result.put("token