相关疑难解决方法(0)

可以在scala中命名常量?

看起来注释需要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中有命名常量?

scala

6
推荐指数
1
解决办法
297
查看次数

标签 统计

scala ×1