【发布时间】:2021-11-22 20:37:30
【问题描述】:
按照指南here 我正在尝试注入我在application.properties 中定义的自定义属性。
prop 定义为sendgrid.apikey=key 然后我的类是;
@ApplicationScoped
public class EmailConfig {
@Inject
@ConfigProperty(name = "sendgrid.apikey")
String API_KEY;
private SendGrid sendGrid;
private Request request;
public EmailConfig() {
sendGrid = new SendGrid(API_KEY);
request = new Request();
}
当我点击构造函数中的第一行时,我希望 API_KEY 是 application.properties 文件中的值,但它是 null。我不知道为什么!顺便说一句,我在有和没有 @Inject 注释的情况下都试过了。
有什么想法吗?
【问题讨论】:
标签: java properties quarkus