Tak Wai Wang
10/03/2025, 1:30 PMBruce Hamilton
10/03/2025, 1:37 PMinstall(DI) {
conflictPolicy = DependencyConflictPolicy { prev, current ->
when (val result = DefaultConflictPolicy.resolve(prev, current)) {
is Conflict -> KeepNew
else -> result
}
}
}
Then you can override dependencies. We should probably have a standard option here for easier config...suresh
10/03/2025, 8:13 PMinstall(DI) , couldn’t find DependencyInjectionBruce Hamilton
10/04/2025, 7:22 AMTak Wai Wang
10/06/2025, 9:03 AMPlease make sure that you use unique name for the plugin and don't install it twice. Conflicting application plugin is already installed with the same key as `DI`
io.ktor.server.application.DuplicatePluginException: Please make sure that you use unique name for the plugin and don't install it twice. Conflicting application plugin is already installed with the same key as `DI`
at io.ktor.server.application.ApplicationPluginKt.install(ApplicationPlugin.kt:137)
But this error does not come up when I start up application.Bruce Hamilton
10/06/2025, 9:17 AMdependencies is called.... if that is already the case, then it could be an issue with it being called from the config fileTak Wai Wang
10/06/2025, 9:40 AMBruce Hamilton
10/06/2025, 9:46 AMBruce Hamilton
10/06/2025, 9:48 AMfun test() = testApplication {
application {
dependencies.provide<MyService> {
MockService()
}
loadServices()
}
}Tak Wai Wang
10/07/2025, 6:42 AMBruce Hamilton
10/07/2025, 6:51 AMtestApplication {
install(DI) {
conflictPolicy = ...
}
application {
// my modules
}
}Tak Wai Wang
10/07/2025, 6:53 AMBruce Hamilton
10/07/2025, 7:05 AMdependencies before the install block... you might need to download the ktor sources and add a breakpoint in io/ktor/server/plugins/di/DependencyInjection.ktBruce Hamilton
10/07/2025, 7:09 AM