forest icon indicating copy to clipboard operation
forest copied to clipboard

注解可否支持直接配置某个bean,而不是通过参数传进来

Open shuohao opened this issue 2 years ago • 1 comments

一般我们会在yml或properties中配置,比如一个业务的请求地址,token什么的。代码会定义一个类接收这个参数,比如 @Data @ConfigurationProperties(prefix = "im-push") public class ImPushProperties {

private String proto;

private String passcode;

private String pushUrl;

} public interface MyClient {

@Get("http://localhost:8080/hello")
String helloForest();

@Get("{imPushProperties.pushUrl}")
String helloForest2();

} ` 然后我希望使用的时候像helloForest2()这样,因为上层调用MyClient时候其实不关心你的配置的url是什么,我只传你要求的参数即可。就好比我调用dubbo服务,我调用的时候不需要我每次去传类似地址这类元数据

shuohao avatar Sep 30 '22 02:09 shuohao

目前还不能直接实现引用 bean 的功能 但可以通过自定义拦截器或自动以注解间接来实现

mySingleLive avatar Oct 10 '22 05:10 mySingleLive