str*_*ash 3 java spring autowired
我正在查看我在工作区中的一些旧例子.由于没有@Autowired,我无法看到自动装配是如何完成的.Spring boot + facebook默认配置.
@Controller
@RequestMapping("/")
public class HelloController {
private Facebook facebook;
private ConnectionRepository connectionRepository;
public HelloController(Facebook facebook, ConnectionRepository connectionRepository) {
this.facebook = facebook;
this.connectionRepository = connectionRepository;
}
@GetMapping
public String helloFacebook(Model model) {
System.out.println("we are here!!!");
if (connectionRepository.findPrimaryConnection(Facebook.class) == null) {
return "redirect:/connect/facebook";
}
PagedList<Post> feed = facebook.feedOperations().getFeed();
model.addAttribute("feed", feed);
return "hello";
}
}
Run Code Online (Sandbox Code Playgroud)
它完美无缺,但这些bean如何在没有@Autowired的情况下自动装配?它们是作为字段还是在构造函数中自动装配?
使用spring boot 1.4+构造函数会自动自动装配
归档时间: |
|
查看次数: |
1625 次 |
最近记录: |