Closed SentryMan closed 3 months ago
@ludmiloff how's this?
@ludmiloff how's this?
@SentryMan, this does not work, at least for me. This is the error:
[2024-04-25 17:01:53,520]-[main] ERROR io.jooby.Jooby - Application initialization resulted in exceptionjava.lang.IllegalStateException: Expecting only 1 bean match but have multiple secondary beans org.jdbi.v3.core.Jdbi@7754195b and org.jdbi.v3.core.Jdbi@7754195b
at jars//io.avaje.inject.spi.DContextEntry$EntryMatcher.checkSecondary(DContextEntry.java:195)
[ERROR] execution of com.Main resulted in exception
io.jooby.exception.StartupException: Application initialization resulted in exception
at io.jooby.Jooby.createApp (Jooby.java:1222)
at io.jooby.Jooby.runApp (Jooby.java:1183)
at io.jooby.Jooby.runApp (Jooby.java:1143)
at com.Main.main (Main.java:10)
Caused by: java.lang.IllegalStateException: Expecting only 1 bean match but have multiple secondary beans org.jdbi.v3.core.Jdbi@7754195b and org.jdbi.v3.core.Jdbi@7754195b
at io.avaje.inject.spi.DContextEntry$EntryMatcher.checkSecondary (DContextEntry.java:195)
at io.avaje.inject.spi.DContextEntry$EntryMatcher.candidate (DContextEntry.java:189)
at io.avaje.inject.spi.DContextEntry$EntryMatcher.findMatch (DContextEntry.java:134)
at io.avaje.inject.spi.DContextEntry$EntryMatcher.match (DContextEntry.java:118)
at io.avaje.inject.spi.DContextEntry.get (DContextEntry.java:53)
at io.avaje.inject.spi.DBeanMap.get (DBeanMap.java:115)
at io.avaje.inject.spi.DBuilder.getMaybe (DBuilder.java:141)
at io.avaje.inject.spi.DBuilder.getBean (DBuilder.java:384)
at io.avaje.inject.spi.DBuilder.get (DBuilder.java:333)
at com.DataCache$DI.build (DataCache$DI.java:20)
where my DataCache class is declared as singleton with constructor like this
@Inject
public DataCache(Jdbi jdbi, Config config) {
......
}
My proposal above works fine, though.
Should I prepare some example code for experiments?
you mean with the @InjectModule(requires={String.class})
thing? For that, you only need to say String.class
once and it'll take care of things. I'll need to make a note of that in the docs.
you mean with the
@InjectModule(requires={String.class})
thing? For that, you only need to sayString.class
once and it'll take care of things. I'll need to make a note of that in the docs.
Yes, this way it works, thanks.
- Using this module needs a special maven/gradle plugin and setup for Avaje code generation
This should only be required if you are running on the module-path and also happen to have custom avaje autoconfig libraries. But yeah it is what it is
First pass at an avaje inject module
helps alleviate #3415