Nacos 配置刷新
1.@Value + @RefreshScope
@RefreshScope
@RestController
public class DemoController {
@Value("${xingyu.publicKey}")
public String publicKey;
}
2.@ConfigurationProperties + @EnableConfigurationProperties
@ConfigurationProperties(prefix = "xingyu.publicKey")
public class DemoProperties implements Serializable {
private String publicKey;
}
@EnableConfigurationProperties({ DemoProperties.class})
public class DemoConfig {
@Autowired
DemoProperties demoProperties;
}