In large application Explicit wiring provide a lot of xml code . To solve out or simplify it use autowiring or implicit wiring. Spring provide four types autowiring-
1. byName-Use to find bean in container whose id is same as the name of the property of specified bean.
(Click to see Example )
2.byType- Use to find bean in container whose type match the type of the property of specified bean. if more than one bean type is found it thrown exception(UnsatisfiedDependencyException).Click to see Example.
3.constructor-Use to match the one or more beans in the container with the parameters of the constructors of the specified bean.(Click to see Example)
4.autodetect-It automatically detect the wiring.basically it autowire constructor first then byType and byName.
(Click to see Example)
==> Spring also provide the autowiring with the annotations.
1. byName-Use to find bean in container whose id is same as the name of the property of specified bean.
(Click to see Example )
2.byType- Use to find bean in container whose type match the type of the property of specified bean. if more than one bean type is found it thrown exception(UnsatisfiedDependencyException).Click to see Example.
3.constructor-Use to match the one or more beans in the container with the parameters of the constructors of the specified bean.(Click to see Example)
4.autodetect-It automatically detect the wiring.basically it autowire constructor first then byType and byName.
(Click to see Example)
==> Spring also provide the autowiring with the annotations.
For Further Reading,
0 comments:
Post a Comment