英文:
Attribute must be constant when get a value from properties
问题
我正在使用Java的javax.ws.rs.Path,并且我正在从属性中获取路径。尽管该常量是final static的,我仍然遇到了“属性必须是常量”的问题。
这是我获取常量值的方式:
public static final String ENDPOINT_GET = ConfigurationProperties.getInstance().getProperty("someProperty");
这是方法的实现:
public String getProperty(String name) {
return properties.getProperty(name);
}
但是我遇到了这个问题,然而,如果我直接将这个常量放在类中,我就不会遇到这个问题。
有什么想法吗?
英文:
I am working with Java javax.ws.rs.Path and I am getting the path from the properties. Even though the constant is final static I am the getting Attribute must be constant issue.
This is my how I am getting the value of my constant:
public static final String ENDPOINT_GET =ConfigurationProperties.getInstance().getProperty("someProperty");}
This is the method Implementation:
public String getProperty(String name) {
return properties.getProperty(name);
}
But I got this issue, in the other hand if I put this constant in the class directly I don't have this issue.
Any idea?
专注分享java语言的经验与见解,让所有开发者获益!
评论