主要問題:未寫 set 方法。
application.properties
jwt.token.secretKey=mwl_secret
jwt.token.expireLength=1800000
JWTPovider
@Component
@ConfigurationProperties(prefix = "jwt.token")
// 必須寫 set 方法 ,即使是 屬性是 public
public class JWTokenProvider {
public String secretKey;
public String expireLength;
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
public void setExpireLength(String expireLength) {
this.expireLength = expireLength;
}
}
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>