Spring boot自定义配置文件并映射到指定类中

新建指定配置类TestConfiguration

该类需要的注解:

@Configuration
@ConfigurationProperties(prefix="test")
@PropertySource("classpath:test.properties")

同时启动类上需要增加注解:

@EnableConfigurationProperties({TestConfiguration.class})
原文地址:https://www.cnblogs.com/wanshiming/p/13438649.html