@Inject를 Autowired와 같이 필드에서 많이 사용해서 필드쪽은 잘 알겠는데, 생성자나 메소드쪽은 잘 안써서,, 정리차 대충 글을 찾아보고 써본다.
@Inject는 @Autowired와 비슷한 의미를 가지고 있다.
@Inject 는 필드, 생성자, 메소드에서 쓰이고 있는데, 간단히 살펴본다.
제일 좋은 문서는 api doc 이다.
https://docs.oracle.com/javaee/6/api/javax/inject/package-summary.html
@inject에 대한 api 이다.
https://docs.oracle.com/javaee/6/api/javax/inject/Inject.html
<필드>
자주 사용하니 패쓰..
<생성자>
일반적으로 생성자 Inject는 여러 생성자 중 하나의 생성자에서 인수를 Inject(주입)시켜 인스턴스를 생성하도록 되어 있다.
좋은 예제
http://www.tutorialspoint.com/spring/constructor_based_dependency_injection.htm
아래 예제는 Facebook에서 개발한 Swift 의 ThriftServer이다. Spring을 이용하여 ThriftServer를 생성하려면 @Inject가 걸려 있는 생성자를 활용하면 된다.
@Inject
public ThriftServer(TProcessor processor, ThriftServerConfig config, @ThriftServerTimer Timer timer)
{
...
}
<메소드>
설명보다 아래 예제에서 잘 설명됨 (prototype, look-up)
좋은 예제
http://java.dzone.com/articles/method-injection-spring
'general java' 카테고리의 다른 글
| Apache commons collection 3.x의 MapUtils 예제 (그리고 주의사항) (0) | 2015.03.15 |
|---|---|
| Spring에서 hbase rest client 설정 예제 및 StringHttpMessageConverter 한글 인코딩 (0) | 2015.03.09 |
| spring @Inject 공부 (0) | 2014.12.09 |
| [java] commons-lang 2에서 3으로 넘어갈 때 주의할 사항 (0) | 2014.10.23 |
| [jenkins] GitHubWebHook ( Not intended to be browsed interactively (must specify payload parameter) 이슈 해결 (0) | 2014.10.06 |
| [jenkins] 설치관련 에러 - dpkg-deb: error: subprocess paste was killed by signal (Broken pipe) (0) | 2014.09.20 |



댓글을 달아 주세요