Using the type safe configuration and configs
( "com.github.kxbmap" %% "configs" % "0.4.4",
) library
def loadConfiguration[T <: Product: TypeTag]: T = {
import configs.syntax._
val conf = ConfigFactory.load
conf.get[MyCaseClass]
should load the config, but fails as T is not a class
. How can I actually transform T
to fit for configs
as a java class?
I'd suggest simply replacing TypeTag
with ClassTag
since you aren't using the TypeTag
.And if you were, you could combine them: T <: Product : TypeTag : ClassTag]
or use this solution: https://stackoverflow.com/a/18730004/9204
From the question I assumed "configs" could work given a Java Class
object (or a ClassTag
wrapping one). But after checking the documentation I see that it doesn't, so the above isn't relevant.
Instead you should use
def loadConfiguration[T : Configs]: T = ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.