Scala “constructor Stopwatch cannot be accessed in class Main”

后端 未结 1 411
小蘑菇
小蘑菇 2021-01-19 16:16

Summary on resolution, I thought I was dealing with a Scala problem but it turns out Stopwatch and Scala Logging have private constructors, and I was not calling the proper

相关标签:
1条回答
  • 2021-01-19 17:07

    The constructors of both Stopwatch and Logger are private. You need to use factory methods to instantiate them.

    In case of the Stopwatch, you could use the createUnstarted() method:

    val stopwatch = Stopwatch.createUnstarted()
    

    In case of Logger, you must use the apply method. However, it requires an underlying SLF4J logger. You can create one through SLF4J's LoggerFactory:

    import org.slf4j.LoggerFactory
    val logger = Logger(LoggerFactory.getLogger(getClass))
    
    0 讨论(0)
提交回复
热议问题