@Overrideide
表示重写this
编译器能够验证@Override下面的方法名是不是父类中全部的spa
@Autowiredcode
使用@Autowired 注解来实现依赖注入orm
能够用在属性、setter方法和构造器上blog
用在属性上get
@Component("fooFormatter") public class FooFormatter { public String format() { return "foo"; } }
@Component public class FooService { @Autowired private FooFormatter fooFormatter; }
The annotation can be used directly on properties, therefore eliminating the need for getters and setters:编译器
In the above example, Spring looks for and injects fooFormatter when FooService is created.it
用在setter上io
public class FooService {
private FooFormatter fooFormatter;
@Autowired public void setFooFormatter(FooFormatter fooFormatter) { this.fooFormatter = fooFormatter; } }
The @Autowired annotation can be used on setter methods. In the above example, when the annotation is used on the setter method, the setter method is called with the instance of FooFormatter when FooServiceis created:
用在构造器上
public class FooService { private FooFormatter fooFormatter; @Autowired public FooService(FooFormatter fooFormatter) { this.fooFormatter = fooFormatter; } }
The @Autowired annotation can also be used on constructors. In the above example, when the annotation is used on a constructor, an instance of FooFormatter is injected as an argument to the constructor when FooService is created:
String...
可变参数
至关于String[]