springboot yml配置文件参数读取
读取yml文件中配置的参数信息
1.yml文件参数内容
im:
ip:
adress: http://XXXXXXXXX
secret: 123456
2.config文件配置读取
@Component
@ConfigurationProperties(prefix = "im.ip")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IMConfig {
private String adress;
private String secret;
}
3.服务类调用
@Service
public class IMMain {
@Autowired
private IMConfig imConfig;
public void Laugher(){
//初始化服务API
AdminHttpUtils.init(imConfig.getAdress(), imConfig.getSecret());
}
}