美文网首页js css html
springboot指定配置文件

springboot指定配置文件

作者: King斌 | 来源:发表于2024-01-21 10:28 被阅读0次

使用 PropertySource 注解

如果在其他自动装配的类中使用了该配置类,就需要使用 AutoConfiguration 注解加入 before 参数,否则获取的参数为null

classpath 默认为项目下的resource目录

在项目目录中的配置会覆盖依赖中的配置

@AutoConfiguration(before = MailConfig.class)
@PropertySource(value = "classpath:common-mail.yml", factory = YmlPropertySourceFactory.class)
@ConfigurationProperties(prefix = "mail")
public class MailProperties {
}

相关文章

网友评论

    本文标题:springboot指定配置文件

    本文链接:https://www.haomeiwen.com/subject/pjkbndtx.html