down votefavorite
<http://stackoverflow.com/questions/39173294/one-can-use-autowired-inside-a-spring-config-but-cannot-use-inject-in-a-guice#>
As far as I can understand, use @Autowired inside a Spring config but
cannot use @Inject in a Guice Module file. Is this true? (JAVA)
I want to use something like this inside the Module class
public class MyModule extends AbstractModule {
@Inject(optional = true)
@Named("TotalQuantity")
private int totalQuantity = 5;
@Provides
@Singleton
Boolean getBoolean()
{
if(totalQuantity>10)
return true;
else
return false;
}
@Override
protected void configure() {}}
Is this the correct way to set the default value, if the dependency is not
provided?
On Friday, 26 August 2016 13:51:19 UTC-7, vishesh kamdar wrote:
>
> So I'm trying to do something like this inside the Module class
>
>
> @Inject(optional = true)@Named("TotalQuantity")private int totalQuantity = 5
>
>
> Is this the correct way to set the default value, if the dependency is not
> provided?
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/1e869cb7-478a-4b08-abf8-b3e6853bbb16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.