标签:singleton spring 配置 强制 name 作用域 set ota 实例
@component
public class Chinese implments Person {
@Autowried
public void setAxe(Axe axe) {
this.axe = axe;
}
}
@component
public class Chinese implments Person {
@Autowried
public void setAxe(Axe axe, Dog dog) {
this.axe = axe;
this.dog = dog
}
...
}
@component
public class Chinese implments Person {
@Autowried
private Axe axe;
@Autowried
public Chinese(Axe axe, Dog dog) {
this.axe = axe;
this.dog = dog
}
...
}
@Component
public class Chinese implements Person {
@Autowired
private Axe[] axes;
...
}
@Component
public class Chinese implements Person {
private Set<Axe> axes;
@Autowired
public void setAxes(Set<Axe> axes) {
this.axes = axes;
}
...
}
public class BaseDaoImpl<T> implements BaseDaoImpl<T> {
public void save(T e) {
System.out.println("程序保存对象:" + e);
}
}
@Component
public class Chinese implements Person {
private Axe axe;
@Resource(name="stoneAxe")
public void setAxe(Axe axe) {
this.axe = axe;
}
}
@DependsOn({"steelAxe","abc"})
@Component
pulic class Chinese implements Person {
...
}
@Lazy(true)
@component
public class Chinese implements Person {
}
@Component
pulic class Chinese implements Person {
@Autowired
@Qualifier("steelAxe")
private Axe axe;
public void setAxe(Axe axe) {
this.axe = axe;
}
public void useAxe() {
System.out.println(axe.chop());
}
}
标签:singleton spring 配置 强制 name 作用域 set ota 实例
原文地址:https://www.cnblogs.com/caoleiCoding/p/9275847.html