看起来注释需要Java中的常量.我想这样做:
object ConfigStatics {
final val componentsToScan = Array("com.example")
}
@PropertySource( ConfigStatics.componentsToScan ) // error: constant value required
class MyConfig extends WebMvcConfigurerAdapter {
}
Run Code Online (Sandbox Code Playgroud)
哪里
@PropertySource( Array("com.example") )
class MyConfig extends WebMvcConfigurerAdapter {
}
Run Code Online (Sandbox Code Playgroud)
很好.
遗憾的是,scala不会将静态最终值视为常量值.
这里有什么可做的,或者它是不可能在scala中有命名常量?
这看起来像一个错误。
SLS 6.24 说文字数组Array(c1, c2, ...)
是常量表达式。
SLS 4.1 表示常量值定义final val x = e
意味着x
被替换为e
。
它不是这样工作的,所以它要么是一个规范错误,要么是一个实现错误。
final val j = Array(1,2,3)
def k = j // j
final val x = 3
def y = x // 3
Run Code Online (Sandbox Code Playgroud)
这是这个问题的重复,其中 Retronym 承诺开具有关此问题的票证。
那是三年前。我想知道他的终端上是否还有一张黄色的便利贴?
归档时间: |
|
查看次数: |
297 次 |
最近记录: |