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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 17249
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How i set Constructor value without <constructor> XML tag ?
 
Similar Threads
read properties in my java application defined in spring bean "PropertyPlaceholderConfigurer"
Using Resource Bundle in XML Config file
@RequestBody unable to bind to XStream POJO.
Order of Execution? Tag Handler or ManagedBean
JSF backingbean value is null always.