Skip to content
Advertisement

Tag: dependency-injection

Prevent injection of bean with narrower scope using Spring

I’m working on a Spring application using beans of different scopes. Many beans are singletons, other request or custom scoped. Especially using those custom scopes makes it sometimes difficult to find out which scope can be safely injected into which other scope or when e.g. a Provider<T> needs to be used. I am aware that I can just create scope

Dagger Component has conflicting scopes

I am using Dagger and I have an app component with @Singleton scope and also a subcomponent with @Singleton scope. Now when I compile it I get this error: [io.droid.nowtellapp.dagger.SignInMvpComponet] io.droid.nowtellapp.dagger.SignInMvpComponet has conflicting scopes: io.droid.nowtellapp.dagger.ApplicationComponent also has @Singleton To resolve this error I removed @Singleton from my subcomponet and compiled it, this time getting this error: Error:(12, 1) error: io.droid.nowtellapp.dagger.SignInMvpComponet

Difference between @Bean and @Autowired

Why can’t I use @Autowired in this case? but can use @Bean Aren’t the two ways to generate BookingService the same thing? Answer @Bean and @Autowired do two very different things. The other answers here explain in a little more detail, but at a simpler level: @Bean tells Spring ‘here is an instance of this class, please keep hold of

Advertisement