Troubleshooting No bean of type [MyFactory] exists #6733
-
We have a framework that was originally creating using Spring/Dagger and I am now working toward migrating it to Micronaut. I've managed to convert the first part/library, with the only real "gotcha" being, that the bean availability management that was originally handled using Spring Configuration files or Dagger Modules (i.e.: beans for each mode defined in specific Config/Module), are now managed using Requires (i.e.: beans from an Active Config/Module are annotated Requires(env="Active")) at either the class or package level. From playing around in a sample app, this seems to work, and the updated library is happily compiling and I can see that the generated Micronaut meta classes are appearing as well. By way of verifying that the switchover worked as expected I'm trying to create some MicronautTest classes to verify that the a given configuration (i.e.: Active) is actually loading, and the beans the library should be providing can be Injected into the MicronautTest class. Everything is compiling properly, however the issue occurs when I try to run the test, and I'm always running into an issue along the line of No bean of type [MyFactory] exists. It's not necessarily always the same Factory that it complains about (but as far as I can tell it's always complaining about a Factory of some kind or other). The factory it is complaining about always has what seem to be the appropriate generated Micronaut classes, such as:
As per the message from the exception, I've enabled trace logging
and while I'm seeing various logging messages for beans that it passes through, I'm never seeing the Factory that it complains about not being able to find. We're using Gradle to pull in the Micronaut dependencies
and the Factories are modeled based on examples I've seen in the documentation and based on what I've created in a little test app where I first played around with Micronaut.
At this point I've been fighting with this for a few days, and I'm very much as a loss as to what could be going on. Everything looks like it should work, but it's not and the error message as best as I can tell is just simply saying "it's not working" without any indication as to why. Any thoughts/ideas as to what could be going on? Any thing that I should look at or check? Maybe I'm just not understanding the output? Below please find the full stacktrace I am receiving when I run the test.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As described in https://docs.micronaut.io/latest/guide/#conditionalBeans try add logging for conditional beans and see what is failing that is causing the bean to be disabled: <logger name="io.micronaut.context.condition" level="DEBUG"/> |
Beta Was this translation helpful? Give feedback.
As described in https://docs.micronaut.io/latest/guide/#conditionalBeans try add logging for conditional beans and see what is failing that is causing the bean to be disabled: