In my project I have two modules:
In com.demo.shared I have a component
@Component
class Address(
    @Value("\${config.address.host}") val host: String,
    @Value("\${config.address.port}") val port: Int
)
In com.demo.app I want to have Spring's IoC container inject the component
@SpringBootApplication
class Application(address: Address) {
    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            SpringApplication.run(Application::class.java, *args)
        }
    }
    private val client: HttpClient("http://${address.host}:${address.port}/")
}
When I run the application I get this error:
Parameter 0 of constructor in com.demo.app.Application required a bean of type 'com.demo.shared.Address' that could not be found.
What am I missing?
NOTE: I've tagged Java because, even though the modules are using Kotlin, if anyone can provide Java examples of what to do, I'll be able to port it relatively easily.
It looks like you just need to add a component scan annotation: http://www.springboottutorial.com/spring-boot-and-component-scan
@ComponentScan(“com.in28minutes.springboot”)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With