我是靠谱客的博主 笨笨项链,这篇文章主要介绍springboot 引入 .yml里的属性值,现在分享给大家,希望可以做个参考。

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.time.Duration;


@Configuration
@PropertySource("classpath:application.yml")
@ConfigurationProperties(prefix = "jwt")
@Data
public class TokenSettings {

    @Value("${secretKey}")
    private String secretKey;
    @Value("${accessTokenExpireTime}")
    private Duration accessTokenExpireTime;
    @Value("${refreshTokenExpireTime}")
    private Duration refreshTokenExpireTime;
    @Value("${refreshTokenExpireAppTime}")
    private Duration refreshTokenExpireAppTime;
    @Value("${issuer}")
    private String  issuer;
}

在这里插入图片描述

最后

以上就是笨笨项链最近收集整理的关于springboot 引入 .yml里的属性值的全部内容,更多相关springboot内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部