Code example for field injection and other changes

This commit is contained in:
Vasudha Venkatesan
2020-03-10 10:55:35 +05:30
parent 1f4484f25f
commit ca32144e80
14 changed files with 205 additions and 43 deletions

View File

@@ -0,0 +1,26 @@
package com.example.dependency;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Pizza {
@Autowired
Topping toppings;
Pizza(Topping toppings) {
this.toppings = toppings;
}
@Autowired
public Topping getToppings() {
System.out.println("Using field injection - " + this.toppings);
return toppings;
}
public void setToppings(Topping toppings) {
this.toppings = toppings;
}
}