aspose file tools*
The moose likes Spring and the fly likes How i set Constructor value without <constructor> XML tag ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How i set Constructor value without <constructor> XML tag ?" Watch "How i set Constructor value without <constructor> XML tag ?" New topic
Author

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

Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

Okay thanks you Mark, very clear explanation.
 
 
subject: How i set Constructor value without <constructor> XML tag ?