• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How i set Constructor value without <constructor> XML tag ?

 
Ranch Hand
Posts: 32
MySQL Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, master

I am new in Spring Framework. For now i learn about Constructor Injection.
But i have one question.

How i can set constructor value not in XML configuration?

Because in my book that i've read it set constructor value in XML with this code :


Thanks before
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Fandy Akhmad wrote:Hello, master

I am new in Spring Framework. For now i learn about Constructor Injection.
But i have one question.

How i can set constructor value not in XML configuration?

Because in my book that i've read it set constructor value in XML with this code :


Thanks before



Well, you can also use a combination of xml and annotations. Where you use the annotation @Autowired (replaces a ref="" version) on the constructor in code. or @Value on the constructor (replaces a value="" version)

So now in xml you only have the <bean> tag and <property> or <constructor-arg> tags are replaced with @Autowired or @Value.

Mark
 
Fandy Akhmad
Ranch Hand
Posts: 32
MySQL Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay thanks you Mark, very clear explanation.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic