We are using a traditional @SpringBootApplication for production and would like to use KoFu for integration tests. We expect faster tests and would like to learn KoFu already until it is ready for production.
For this, we like to share our bean definitions
val moduleBeans = beans {
bean<MyHandler>()
bean<MyService>()
bean(::routes)
}
between production
@SpringBootApplication
class MyApplication
fun main() {
runApplication<MyApplication> {
addInitializers(moduleBeans)
}
}
and the KoFu app for integration tests
val app = reactiveWebApplication {
webFlux {
[...]
}
// we would like to include moduleBeans here without code duplication
}
We have found only one way to make sharing the stand-alone bean definitions work:
fun BeanDefinitionDsl.moduleBeans() {
bean<MyHandler>()
bean<MyService>()
bean(::routes)
}
We are using a traditional
@SpringBootApplication
for production and would like to use KoFu for integration tests. We expect faster tests and would like to learn KoFu already until it is ready for production.For this, we like to share our bean definitions
between production
and the KoFu app for integration tests
We have found only one way to make sharing the stand-alone bean definitions work:
and in the DSL
That's not very elegant. Did we miss something? If not, how about adding
or even
to
ConfigurationDsl
so we can simply enable the bean definition? This also allows a step-by-step migration from a
SpringBootApplication
by starting with programmatic bean registration.