If you are not sure if the website you would like to visit is secure, you can verify it here. Enter the website address of the page and see parts of its content and the thumbnail images on this site. None (if any) dangerous scripts on the referenced page will be executed. Additionally, if the selected site contains subpages, you can verify it (review) in batches containing 5 pages.
favicon.ico: dineshonjava.com/constructor-object-injecting - Setter vs Constructor Injectio.

site address: dineshonjava.com/constructor-object-injecting/ redirected to: dineshonjava.com/constructor-object-injecting

site title: Setter vs Constructor Injection in Spring Example - Dinesh on Java

Our opinion (on Thursday 19 November 2026 13:52:08 UTC):

GREEN status (no comments) - no comments
After content analysis of this website we propose the following hashtags:



Meta tags:
description=In this article we will discuss Constructor Injection and Setter Injection. These are two ways to define the dependency injection in the spring application.;
author=;

Headings (most frequently used words):

spring, injection, example, setter, constructor, in, the, bean, and, aop, advice, vs, injecting, object, user, define, to, difference, between, applicationcontext, webapplicationcontext, mvc, data, mongodb, delete, document, beanfactory, implementation, after, throwing, using, xml, config, aspectj, around, annotation, life, cycle, callbacks, share, this, related, posts, about, author, comments, dinesh, rajput,

Text of the page (most frequently used words):
#spring (148), the (124), org (69), springframework (66), and (64), triangle (63), bean (54), http (48), www (48), schema (45), type (41), class (39), aop (38), tutorial (38), property (34), beans (32), context (30), height (30), java (28), interview (27), example (27), xml (27), public (26), constructor (26), injection (25), security (24), point (22), name (21), int (21), this (20), value (20), with (19), pointa (18), xmlns (18), new (17), pointc (17), pointb (17), string (17), attribute (17), private (17), factory (16), used (16), 2012 (15), support (15), xsd (15), void (14), element (14), dineshonjava (13), com (13), sdnext (13), set (13), boot (12), dinesh (12), advice (12), jun (12), setter (12), param (11), core (10), has (10), using (10), microservices (9), questions (9), design (9), info (9), classpathxmlapplicationcontext (9), object (9), web (8), applicationcontext (8), from (8), now (8), define (8), two (8), mvc (7), hibernate (7), rajput (7), author (7), annotation (7), share (7), dependency (7), package (7), injectingobject (7), draw (7), specify (7), arg (7), index (7), jax (6), framework (6), aspectj (6), config (6), opens (6), window (6), configuration (6), answers (6), defaultlistablebeanfactory (6), root (6), hierarchy (6), import (6), drawingapp (6), args (6), main (6), properties (6), following (6), xsi (6), equilateral (6), constructorinjection (6), are (6), rest (5), after (5), output (5), here (5), for (5), ref (5), which (5), system (5), out (5), println (5), argument (5), cloud (4), soap (4), patterns (4), batch (4), application (4), one (4), related (4), previous (4), beanfactory (4), will (4), annotations (4), ioc (4), container (4), you (4), such (4), its (4), return (4), getx (4), gety (4), all (4), drawn (4), attributes (4), service (3), jdbc (3), struts (3), services (3), tutorials (3), hateoas (3), development (3), architecture (3), june (3), technologies (3), pattern (3), different (3), about (3), around (3), next (3), transaction (3), management (3), before (3), like (3), pre (3), instantiating (3), singletons (3), 14c1103 (3), defining (3), preinstantiatesingletons (3), loading (3), definitions (3), path (3), resource (3), xmlbeandefinitionreader (3), loadbeandefinitions (3), refreshing (3), startup (3), date (3), ist (3), abstractapplicationcontext (3), preparerefresh (3), static (3), xmlbeanfactory (3), filesystemresource (3), getbean (3), another (3), respectively (3), get (3), display (3), represents (3), specifies (3), corresponding (3), inject (3), via (3), fully (3), qualified (3), 2001 (3), xmlschema (3), instance (3), schemalocation (3), points (3), see (3), pubic (3), user (3), have (3), that (3), can (3), then (3), collaborators (3), privacy (2), policy (2), who (2), training (2), linux (2), git (2), thymeleaf (2), mongo (2), ant (2), gradle (2), maven (2), build (2), tools (2), ajax (2), hadoop (2), mail (2), api (2), jstl (2), jsp (2), servlet (2), j2ee (2), computing (2), wsdl (2), search (2), mobile (2), certification (2), monitoring (2), testing (2), react (2), learn (2), solve (2), common (2), problems (2), very (2), anonymous (2), comments (2), technical (2), been (2), aspects (2), his (2), latest (2), mongodb (2), company (2), developer (2), life (2), cycle (2), callbacks (2), throwing (2), data (2), between (2), pinterest (2), telegram (2), whatsapp (2), linkedin (2), facebook (2), injecting (2), discuss (2), based (2), aspect (2), method (2), jsr (2), may (2), point2 (2), point3 (2), these (2), also (2), file (2), three (2), axis (2), only (2), double (2), examples (2), etc (2), types (2), 145d068 (2), wed (2), run (2), console (2), viz (2), settype (2), basic (2), defaults (2), arguments (2), lang (2), there (2), need (2), copyright, 2026, hands, performance, engineer, guide, continuous, let, full, stack, designing, applications, native, various, use, them, best, practices, nice, good, chief, editor, website, blog, dedicated, series, articles, enthusiast, since, 2008, pivotal, certified, professional, book, blogger, more, than, years, experience, expertise, lies, version, creating, apis, microservice, reactive, cassandra, currently, working, technology, manager, leading, product, worked, tech, lead, bennett, coleman, ltd, was, first, paytm, passionate, loves, write, blogs, active, member, community, forums, when, comes, tops, list, implementation, delete, document, difference, webapplicationcontext, posts, inner, chapter, namespace, ordering, declarative, proxies, afterthrowing, returning, afterreturning, introduction, oriented, programming, lookup, component, repository, controller, stereotype, 330, 250, beanfactorypostprocessor, beanpostprocessor, applicationcontextaware, create, custom, scope, scopes, autowiring, what, topics, zeropoint, ab50cd, sat, point1, reference, actually, configure, both, setx, sety, nodes, required, setpointa, setpointb, setpointc, lets, area, above, seen, how, definition, initialized, associated, defined, integer, primitive, long, setheight, ideas, creates, call, override, order, wire, graph, together, replace, key, test, doubles, setters, reasonable, sequences, passes, any, second, say, distinguished, idea, instead, single, where, values, supplied, instantiate, webservice, popular, historically, come, whereas, lightweight, googles, google, guice, picocontainer, article, ways, dependencies, each, other, home,


Text of the page (random words):
rk org schema beans xsi schemalocation http www springframework org schema beans http www springframework org schema beans spring beans 2 5 xsd http www springframework org schema context http www springframework org schema context spring context 2 5 xsd http www springframework org schema security http www springframework org schema security spring security 2 0 4 xsd http www springframework org schema aop http www springframework org schema aop spring aop 2 5 xsd http www springframework org schema tx http www springframework org schema tx spring tx 2 5 xsd bean class com dineshonjava sdnext constructorinjection tutorial triangle id triangle constructor arg index 0 type java lang string value equilateral constructor arg constructor arg index 1 type int value 20 constructor arg bean beans the id attribute of the bean element is used to specify the bean name and the class attribute is used to specify the fully qualified class name of the bean the constructor arg element with in the bean element is used to inject property value via constructor injection the index attribute of the constructor arg element represents the constructor argument sequences which passes to the constructor of the class such as triangle string type int height at index 0 argument is type and at index 1 argument is height and so on if any class has one argument constructor then there are no need to specify the index attribute of the bean in the bean configuration in spring i e we can say index attribute used to distinguished to arguments of the constructor now second attribute is type of the constructor arg it is used for type of the arguments of the constructor such as triangle string type int height then type java lang string and type int and the value attribute specifies the corresponding property value here we set equilateral and 20 for the triangle bean properties type and height respectively the following main class is used to get the triangle bean from the spring ioc container and display its value it to the triangle drawingapp java package com dineshonjava sdnext constructorinjection tutorial import org springframework context applicationcontext import org springframework context support classpathxmlapplicationcontext author dinesh rajput public class drawingapp param args public static void main string args triangle triangle new triangle beanfactory factory new xmlbeanfactory new filesystemresource spring xml applicationcontext context new classpathxmlapplicationcontext spring xml triangle triangle triangle context getbean triangle triangle draw now we run this example the following output on the console output jun 20 2012 12 12 25 am org springframework context support abstractapplicationcontext preparerefresh info refreshing org springframework context support classpathxmlapplicationcontext 145d068 startup date wed jun 20 00 12 25 ist 2012 root of context hierarchy jun 20 2012 12 12 25 am org springframework beans factory xml xmlbeandefinitionreader loadbeandefinitions info loading xml bean definitions from class path resource spring xml jun 20 2012 12 12 26 am org springframework beans factory support defaultlistablebeanfactory preinstantiatesingletons info pre instantiating singletons in org springframework beans factory support defaultlistablebeanfactory 14c1103 defining beans triangle root of factory hierarchy equilateral triangle is drawn of height 20 setter injection the basic ideas is that you have a no argument constructor which creates the object with reasonable defaults the user of the object can then call setters on the object to override the collaborators of the object in order to wire the object graph together or to replace the key collaborators with test doubles now we see an example which has constructor injection type dependency triangle java package com sdnext constructorinjection tutorial author dinesh rajput public class triangle private string type private int height param type the type to set public void settype string type this type type param height the height to set public void setheight string height this height height public void draw system out println this type triangle is drawn of height this height the triangle bean class has two attributes viz type and height all the two attributes are set using the setter injection spring xml beans xmlns aop http www springframework org schema aop xmlns p http www springframework org schema p xmlns security http www springframework org schema security xmlns tx http www springframework org schema tx xmlns xsi http www w3 org 2001 xmlschema instance xmlns http www springframework org schema beans xsi schemalocation http www springframework org schema beans http www springframework org schema beans spring beans 2 5 xsd http www springframework org schema context http www springframework org schema context spring context 2 5 xsd http www springframework org schema security http www springframework org schema security spring security 2 0 4 xsd http www springframework org schema aop http www springframework org schema aop spring aop 2 5 xsd http www springframework org schema tx http www springframework org schema tx spring tx 2 5 xsd bean class com dineshonjava sdnext constructorinjection tutorial triangle id triangle property name type value equilateral property name height value 20 property property bean beans the id attribute of the bean element is used to specify the bean name and the class attribute is used to specify the fully qualified class name of the bean the property element with in the bean element is used to inject property value via setter injection the name attribute of the property element represents the bean attribute and the value attribute specifies the corresponding property value here we set equilateral and 20 for the triangle bean properties type and height respectively the following main class is used to get the triangle bean from the spring ioc container and display its value it to the triangle drawingapp java package com dineshonjava sdnext constructorinjection tutorial import org springframework context applicationcontext import org springframework context support classpathxmlapplicationcontext author dinesh rajput public class drawingapp param args public static void main string args triangle triangle new triangle beanfactory factory new xmlbeanfactory new filesystemresource spring xml applicationcontext context new classpathxmlapplicationcontext spring xml triangle triangle triangle context getbean triangle triangle draw now we run this example the following output on the console output jun 20 2012 12 12 25 am org springframework context support abstractapplicationcontext preparerefresh info refreshing org springframework context support classpathxmlapplicationcontext 145d068 startup date wed jun 20 00 12 25 ist 2012 root of context hierarchy jun 20 2012 12 12 25 am org springframework beans factory xml xmlbeandefinitionreader loadbeandefinitions info loading xml bean definitions from class path resource spring xml jun 20 2012 12 12 26 am org springframework beans factory support defaultlistablebeanfactory preinstantiatesingletons info pre instantiating singletons in org springframework beans factory support defaultlistablebeanfactory 14c1103 defining beans triangle root of factory hierarchy equilateral triangle is drawn of height 20 injecting object user define to the bean in the above examples we have been seen that how to define the bean triangle definition in the configuration file spring xml and initialized its associated properties type and height in previous examples we only used primitive data types int long double etc and java defined class such as like string integer etc for example type is string and height is int pubic class triangle private int height private string type private double area now we will define a bean triangle with user define properties point class pubic class triangle private point pointa private point pointb private point pointc pubic class point private int x private int y lets see with the example triangle java package com dineshonjava sdnext injectingobject tutorial public class triangle private point pointa private point pointb private point pointc param pointa the pointa to set public void setpointa point pointa this pointa pointa param pointb the pointb to set public void setpointb point pointb this pointb pointb param pointc the pointc to set public void setpointc point pointc this pointc pointc public void draw system out println pointa is pointa getx pointa gety system out println pointb is pointb getx pointb gety system out println pointc is pointc getx pointc gety triangle class has three points of nodes to draw a triangle and define setter of all three points pointa pointb and pointc only setter is required in the spring framework here point is also a class with two points one is x axis and another is y axis point java package com dineshonjava sdnext injectingobject tutorial public class point private int x private int y return the x public int getx return x param x the x to set public void setx int x this x x return the y public int gety return y param y the y to set public void sety int y this y y here we define the point class with two properties int x int y actually point class is also a bean which is as a property of the triangle bean now we will configure both beans to the configuration file spring xml spring xml beans xmlns aop http www springframework org schema aop xmlns p http www springframework org schema p xmlns security http www springframework org schema security xmlns tx http www springframework org schema tx xmlns xsi http www w3 org 2001 xmlschema instance xmlns http www springframework org schema beans xsi schemalocation http www springframework org schema beans http www springframework org schema beans spring beans 2 5 xsd http www springframework org schema context http www springframework org schema context spring context 2 5 xsd http www springframework org schema security http www springframework org schema security spring security 2 0 4 xsd http www springframework org schema aop http www springframework org schema aop spring aop 2 5 xsd http www springframework org schema tx http www springframework org schema tx spring tx 2 5 xsd bean class com dineshonjava sdnext injectingobject tutorial triangle id triangle property name pointa ref pointa property property name pointb ref pointb property property name pointc ref pointc property bean bean class com dineshonjava sdnext injectingobject tutorial point id pointa property name x value 0 property property name y value 0 property bean bean class com dineshonjava sdnext injectingobject tutorial point id pointb property name x value 20 property property name y value 0 property bean bean class com dineshonjava sdnext injectingobject tutorial point id pointc property name x value 20 property property name y value 0 property bean beans the id attribute of the bean element is used to specify the bean name and the class attribute is used to specify the fully qualified class name of the bean the property element with in the bean element is used to inject property value via setter injection the name attribute of the property element represents the bean attribute and the ref attribute specifies the reference of another bean or id of the bean element point corresponding property here we set pointa pointb and pointc properties name for the triangle bean with ref id of another bean point pointa pointb and pointc these id name may be different such like point1 point2 and point3 respectively now pointa is the id of bean element of one point class and so on the following main class is used to get the triangle bean from the spring ioc container and display its value it to the triangle drawingapp java package com dineshonjava sdnext injectingobject tutorial import org springframework context applicationcontext import org springframework context support classpathxmlapplicationcontext author dinesh rajput public class drawingapp param args public static void main string args beanfactory factory new xmlbeanfactory new filesystemresource spring xml applicationcontext context new classpathxmlapplicationcontext spring xml triangle triangle triangle context getbean triangle triangle draw output jun 23 2012 12 30 25 pm org springframework context support abstractapplicationcontext preparerefresh info refreshing org springframework context support classpathxmlapplicationcontext ab50cd startup date sat jun 23 12 30 25 ist 2012 root of context hierarchy jun 23 2012 12 30 26 pm org springframework beans factory xml xmlbeandefinitionreader loadbeandefinitions info loading xml bean definitions from class path resource spring xml jun 23 2012 12 30 26 pm org springframework beans factory support defaultlistablebeanfactory preinstantiatesingletons info pre instantiating singletons in org springframework beans factory support defaultlistablebeanfactory 14c1103 defining beans triangle zeropoint point2 point3 root of factory hierarchy pointa is 0 0 pointb is 20 0 pointc is 20 0 spring related topics you may like spring interview questions and answers spring aop interview questions and answers spring mvc interview questions spring security interview questions and answers spring rest interview questions and answers spring boot interview questions and answers spring boot microservices interview questions and answers dependency injection di in spring spring ioc container what is bean factory in spring applicationcontext in spring bean autowiring in spring spring bean scopes create custom bean scope in spring example using applicationcontextaware in spring spring bean life cycle and callbacks beanpostprocessor in spring beanfactorypostprocessor in spring annotations in spring and based configuration spring jsr 250 annotations jsr 330 annotations in spring spring component repository service and controller stereotype annotations method injection with spring using lookup method property spring aop introduction to aspect oriented programming aspect annotation in spring spring aop aspectj before annotation advice example spring aop before advice example using xml config spring aop aspectj after annotation advice example spring aop after advice example using xml config spring aop aspectj afterreturning annotation advice example spring aop after returning advice example using xml config spring aop aspectj afterthrowing annotation advice example spring aop after throwing advice example using xml config spring aop aspectj around annotation advice example spring aop around advice example using xml config spring aop proxies in spring spring aop transaction management in hibernate spring transaction management spring declarative transaction management example spring aop ordering of aspects with example spring security java based configuration with example spring security xml namespace configuration example in next chapter we will discuss about injecting inner beans in spring with ex...
Thumbnail images (randomly selected): * Images may be subject to copyright.GREEN status (no comments)
  • Setter and Constructor In...
  • Spring-5-Design-Pattern
  • Designing Applications wi...

Verified site has: 99 subpage(s). Do you want to verify them? Verify pages:

1-5 6-10 11-15 16-20 21-25 26-30 31-35 36-40 41-45 46-50
51-55 56-60 61-65 66-70 71-75 76-80 81-85 86-90 91-95 96-99


Top 50 hastags from of all verified websites.

Supplementary Information (add-on for SEO geeks)*- See more on header.verify-www.com

Header

HTTP/1.1 301 Moved Permanently
Date Thu, 19 Nov 2026 13:52:07 GMT
Content-Type text/html
Content-Length 795
Connection close
location htt????/dineshonjava.com/constructor-object-injecting/
platform hostinger
panel hpanel
content-security-policy upgrade-insecure-requests
Server hcdn
alt-svc h3= :443 ; ma=86400
x-hcdn-request-id 2c86afd3404a2cbd658ff780df42bcb5-int-edge9
x-hcdn-cache-status MISS
x-hcdn-upstream-rt 0.155
HTTP/2 200
date Thu, 19 Nov 2026 13:52:08 GMT
content-type text/html; charset=UTF-8
vary Accept-Encoding
x-powered-by PHP/8.3.36
link <htt????/dineshonjava.com/wp-json/>; rel= htt????/api.w.org/
link <htt????/dineshonjava.com/wp-json/wp/v2/posts/676>; rel= alternate ; title= JSON ; type= application/json
link <htt????/wp.me/p94H1c-aU>; rel=shortlink
etag 181-1795096328;gz
x-litespeed-cache miss
content-encoding gzip
platform hostinger
panel hpanel
content-security-policy upgrade-insecure-requests
x-endurance-cache-level 2
x-nginx-cache WordPress
server hcdn
alt-svc h3= :443 ; ma=86400
x-hcdn-request-id a4ba863cc0e3fbcc6de539b5499f4dc7-int-edge7
x-hcdn-cache-status MISS
x-hcdn-upstream-rt 0.914

Meta Tags

title="Setter vs Constructor Injection in Spring Example - Dinesh on Java"
charset="UTF-8"
name="msapplication-TileImage" content="htt????/i0.wp.com/dineshonjava.com/wp-content/uploads/2017/08/favicon.png?fit=177%2C106&ssl=1"
name="viewport" content="width=device-width, initial-scale=1"
name="apple-mobile-web-app-capable" content="yes"
name="apple-mobile-web-app-status-bar-style" content="black"
itemprop="name" content="Dinesh on Java"
itemprop="url" content="htt????/dineshonjava.com"
itemprop="creator accountablePerson" content="Dinesh Rajput"
name="robots" content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1"
name="description" content="In this article we will discuss Constructor Injection and Setter Injection. These are two ways to define the dependency injection in the spring application."
property="og:locale" content="en_US"
property="og:type" content="article"
property="og:title" content="Setter vs Constructor Injection in Spring Example - Dinesh on Java"
property="og:description" content="In this article we will discuss Constructor Injection and Setter Injection. These are two ways to define the dependency injection in the spring application."
property="og:url" content="htt????/dineshonjava.com/constructor-object-injecting/"
property="og:site_name" content="Dinesh on Java"
property="article:publisher" content="htt????/www.facebook.com/thedineshonjava/"
property="article:author" content="htt????/www.facebook.com/thedineshonjava/"
property="article:published_time" content="2012-06-18T01:09:00+00:00"
property="article:modified_time" content="2017-11-25T12:12:43+00:00"
property="og:image" content="htt????/i1.wp.com/dineshonjava.com/wp-content/uploads/2012/06/spring-setter-constructor-injections.jpg?fit=571%2C343&ssl=1"
property="og:image:width" content="571"
property="og:image:height" content="343"
property="og:image:type" content="image/jpeg"
name="author" content="Dinesh Rajput"
name="twitter:card" content="summary_large_image"
name="twitter:creator" content="@dineshonjava"
name="twitter:site" content="@dineshonjava"
name="twitter:label1" content="Written by"
name="twitter:data1" content="Dinesh Rajput"
name="twitter:label2" content="Est. reading time"
name="twitter:data2" content="13 minutes"
name="generator" content="AMP for WP 1.1.20"
name="generator" content="WordPress 7.1.4"
name="msapplication-TileImage" content="htt????/i0.wp.com/dineshonjava.com/wp-content/uploads/2017/08/favicon.png?fit=177%2C106&ssl=1"

Load Info

page size26594
load time (s)1.184742
redirect count1
speed download22461
server IP 147.79.119.12
* all occurrences of the string "http://" have been changed to "htt???/"