I am trying to use Spring with Scala. I know Autowired works with Scala class, but I am using a web-framework that requires an object and I want to inject a dao into it. I w
I faced same issue.
I have many services and want to call these @Autowired service from scala objects.
I tried all the above, None of them worked as my expectation.
I have an object named JobConfig.scala
and I want to autowire TableResolver
class and TableResolver
class itself autowire many other classes.
My application is in spring boot and scala.
src/main/resources/applicationContext.xml
file.
XmlBeansConfig.scala
import org.springframework.context.annotation.{Configuration, ImportResource}
@Configuration
@ImportResource(value = Array("classpath*:applicationContext.xml"))
class XmlBeansConfig {
}
JobConfig.scala
object JobConfig{
def getInstance = this
@Autowired
var tableResolver: TableResolver = _
}