How to Inject OneScope bean into another ( PrototypeBean into SingletonBean injection )
spring injection of one bean
in to other is known as autowiring
. Autowiring of
the beans are five types
1. no
2. bytheName
3. bytheType
4. constructor
5.autodetect
you can
inject bean
using @Autowire annotation or using bean
configuration in
Context file .
Here is general example of
the injection
<bean id="a" class="A">
<property name="b"
ref="b"/>
</bean>
<bean id="b" class="B"
scope="session"/> or
<bean id="b" class="B"
scope="prototype"/>
So
here by default bean
(a ) is singleton scope and we
are injecting
(b) bean with
scope of session or prototype .
We inject singleton into prototype using annotation
.
Here is example
Bean with scope singleton
@Scope(value = "singleton")
@Component
public class Name {
private String firstName = " mak";
private String lastName = " com";
getter and setter
}
Bean with scope prototype
@Scope(value = "prototype", proxyMode =
ScopedProxyMode.TARGET_CLASS))
@Component
public class Language {
private String language = "English";
getter and setter
}
Bean injections
@Component
public class Customer {
@Autowired
private Language language;
@Autowired
private Name name;
}
Again Customer default scope is singleton and we
are injecting two beans
with scope singleton and prototype.
How to Inject OneScope bean into another ( PrototypeBean into SingletonBean injection )
Reviewed by Mukesh Jha
on
4:50 AM
Rating:
Reviewed by Mukesh Jha
on
4:50 AM
Rating:


DABA7F5F61
ReplyDeleteTakipçi Satın Al
Footer Link Satın Al
MMORPG Oyunlar
Pokemon GO Promosyon Kodu
Avast EtkinleÅŸtirme Kodu
FE5CE7A1
ReplyDeleterus esçort İzmir
antakya esçort
görüntülü seks
fatsa esçort
esçort batman
esçort bayan amasya
kulu esçort
esçort bayan erzurum
burdur esçort