Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否可以根据 配置文件是否有相应配置来建立 bean #72

Closed
coolyu0916 opened this issue Aug 2, 2021 · 4 comments
Closed

Comments

@coolyu0916
Copy link

coolyu0916 commented Aug 2, 2021

@RetrofitClient(baseUrl = "${test.baseUrl}")
public interface HttpApi {

@GET("person")
Result<Person> getPerson(@Query("id") Long id);

}
如果yml中没有test.baseUrl 能否不创建bean,而是提示一个警告?
或者用@conditionalonproperty 来作判断?

或者 baseURL 支持 SpEL?

@chentianming11
Copy link
Collaborator

不清楚什么场景会出现这种情况。我个人觉得没有配置算是很严重的问题,所以倾向于启动时提前暴露问题。

@chentianming11
Copy link
Collaborator

@conditionalonproperty 可以考虑支持

@coolyu0916
Copy link
Author

场景是我想将一些经常用的API封装成自己的starter方便引入调用,但是这些API不是每个应用都需要用到,所以想通过是否经过了配置来决定是否生成bean。已经自定义重写了 AutoConfiguredRetrofitScannerRegistrar 和 ClassPathRetrofitClientScanner 来解决了这个问题,但是编码有些硬,想知道有没有更好的方法。

@chentianming11
Copy link
Collaborator

chentianming11 commented Aug 5, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants