属性在从属性中获取值时必须是常量。

huangapple 未分类评论45阅读模式
英文:

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?

huangapple
  • 本文由 发表于 2020年4月11日 04:11:32
  • 转载请务必保留本文链接:https://java.coder-hub.com/61147961.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定