This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
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
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Reply 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: 17243
    
    1

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How i set Constructor value without <constructor> XML tag ?
 
Similar Threads
read properties in my java application defined in spring bean "PropertyPlaceholderConfigurer"
Order of Execution? Tag Handler or ManagedBean
@RequestBody unable to bind to XStream POJO.
Using Resource Bundle in XML Config file
JSF backingbean value is null always.