springboot中使用@Value给变量赋值

给普通变量赋值

在这里插入图片描述

@Component
@PropertySource("classpath:application.properties")
@ConfigurationProperties(prefix = "path")
@Getter
@Setter
public class ConstantsUrl {
    @Value("${path.rootPath}")
    private String rootPath;

    @Value("${path.BPath}")
    private String BPath;

    @Value("${path.GPath}")
    private String GPath;

    @Value("${path.TPath}")
    private String TPath;

    @Value("${path.IPath}")
    private String IPath;

    @Value("${path.BbulPath}")
    private String BbulPath;

    @Value("${path.GbulPath}")
    private String GbulPath;

    @Value("${path.TbulPath}")
    private String TbulPath;

    @Value("${path.IbulPath}")
    private String IbulPath;

    @Value("${path.BlsPath}")
    private String BlsPath;

    @Value("${path.GlsPath}")
    private String GlsPath;

    @Value("${path.TlsPath}")
    private String TlsPath;

    @Value("${path.IlsPath}")
    private String IlsPath;

    @Value("${path.BACKUP_root_path}")
    private String BACKUP_root_path;

调用

在这里插入图片描述
在这里插入图片描述

给静态变量赋值

在这里插入图片描述

调用

在这里插入图片描述

发布了7 篇原创文章 · 获赞 0 · 访问量 123

猜你喜欢

转载自blog.csdn.net/zq6269/article/details/104823958