question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Named BeanDefinition not using 'primary_type'

See original GitHub issue

Describe the bug When defining two objects with same named string, it fails with DefinitionOverrideException

To Reproduce Steps to reproduce the behavior:

  1. Create definitions like:
factory(named("statusOne")){ StatusObject(get(named("statusOne"))) }
single(named("statusOne")){ StatusObjectConstructorParam() }
  1. start app… startKoin{...}

Expected behavior named definitions also check primary_type to determine object definition

Koin project used and used version (please complete the following information):

    implementation "org.koin:koin-androidx-scope:2.0.1"
    implementation "org.koin:koin-androidx-viewmodel:2.0.1"
    implementation "org.koin:koin-androidx-ext:2.0.1"

this appeard after migrating from 1.0.2 to 2.0.1 - on 1.x it such definitions were working fine, on 2.x every named (eg. based on enums) definitions should be changed, which is painful job 😉 or there is some other way I didn’t in docs?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
arnaudgiulianicommented, Oct 4, 2019

Hello @bovquier,

this behavior is intended: a qualifier is unique for all definitions. What is your use case behind reusing the same qualifier?

0reactions
ghostcommented, Oct 23, 2019

@arnaudgiuliani the reason is eg. I’m using ItemKeyedDataSource and DataSource.Factory from jetpack paging, and same implementations for few source types (eg. based on item status), this doesn’t allow me to make them defined in simple way like in Kotlin1 (have such setup for that). In Koin2, this will need to create ActiveDataSource/PendingDataSource/LockedDataSource, to match the requirements. In Koin1 I have something like:

        MyProjectsAdapter.ProjectsPagesItems.values().forEach { page -> single(page.name) { ProjectsDataSourceFactory() } }
        MyProjectsAdapter.ProjectsPagesItems.values().forEach { page -> factory(page.name) { ProjectsDataSourceManager(get(page.name)) } }

and I have 2 lines, and do not think about how many PagesTypes there will be, all adapter pages will have its sources injected. But couldn’t achive that in K2, but I may be missing something in docs, and you, guys, can give some hint, if there is such simple approach for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocked named beans in Spring configuration without using ...
Mocked named beans in Spring configuration without using allow-bean-definition-overriding? ... I have two beans with the same signature. They are ...
Read more >
Core Technologies - Spring
Motivations for not supplying a name are related to using inner beans and autowiring collaborators. Bean Naming Conventions. The convention is to use...
Read more >
Choosing from multiple beans in the context - Manning
Using the @Qualifier annotation, I specify the name of the bean I want Spring to inject from the context, and I don't rely...
Read more >
Installing Hippo Channel Manager Page Management Support
... your SITE application to shadow the file with a custom bean definition. ... < sv:property sv:name = "jcr:primaryType" sv:type = "Name" >....
Read more >
Spring NoSuchBeanDefinitionException - Baeldung
Now if the dependency BeanB is not defined in the Spring Context, the bootstrap process will fail with the no such bean definition...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found