Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay thanks you Mark, very clear explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic