페이지 100 의 내용중에
의존성 주입 어노테이션 이라는 의존성 주입설정이 있다.
첫번째 @Autowired를 사용하는데
우선 sonySpeaker가 메모리상에 생성 되어야 한다. 내가 실습하는 동안 에러가 발생하였는데
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private polymorphism.Speaker polymorphism.LgTV.speaker; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [polymorphism.Speaker] is defined: expected single matching bean but found 2: apple,sony
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 12 more
원인 부분만 보면 싱글 매칭이 예상되지만 2개를 찾았다. 애플, 소니
그러니까 설정파일에서 애플 스피커와 소니 스피커 두개가있는데 어느걸쓸거냐 라고 물어보는듯 하다.
애플스피커 내용을 xml설정 파일에서 지워주면 에러는 발새하지 않으나 만약 애플스피커커 객체를 메모리에 만들어놔야하는 경우도 있을것같다.
No qualifying bean of type [polymorphism.Speaker] is defined: expected single matching bean but found 2: sony,apple
좀더 읽어보니 이럴경우에는 @Qualifier를 사용하여 주입될 객체를 지정해주면된다.
실습중에 126페이지 보드의 비즈니스 로직에 관련하여 발견된 에러이다.
Exception in thread "main" java.lang.ClassCastException: com.springbook.biz.board.impl.BoardServiceImpl cannot be cast to com.springbook.biz.board.BoardService
at com.springbook.biz.board.BoardServiceClient.main(BoardServiceClient.java:15)
해결 )
BoardSerivceImpl.java에서
public class BoardServiceImpl implements BoardService
부분을 누락함 BoardService는 인터페이스인데 이부분을 누락하니까
형변환이 안된다고 에러를 보임.
실습중에 137페이지 유저 로그인 이 안된다
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
INFO : org.springframework.context.support.GenericXmlApplicationContext - Refreshing org.springframework.context.support.GenericXmlApplicationContext@c2e1f26: startup date [Tue Aug 09 15:08:29 KST 2016]; root of context hierarchy
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
로그인 실패
INFO : org.springframework.context.support.GenericXmlApplicationContext - Closing org.springframework.context.support.GenericXmlApplicationContext@c2e1f26: startup date [Tue Aug 09 15:08:29 KST 2016]; root of context hierarchy
에러가 안나오며 그냥 로그인실패라고만 나온다. user가 널이란 얘긴데
이럴땐 어찌해야하는가 ㅠㅠ
해결)
이클립스에서 자동으로 생성되는 겟 메서드 기능을 이용하면
메서드 구문이 자동으로 완성된다.
그런데 문제는 메서드 안의 내용은 직접입력해줘야하는데 초보자인 나는 그냥 넘어가버렸다.
return 문에 적절한 내용을 넣지 않고 그냥 return null;
이렇게 되니 유저도 널 나도 널 시간도 널널하게 날아간다
2016년 8월 8일 월요일
피드 구독하기:
댓글 (Atom)
-
운영체제를 다시 설치할때 보통 윈도우 인스톨러인가 UUI ? 뭐 정확히는몰라도 여러가지 프로그램을 사용하는데 이번에 rufus 라는 프로그램을 접하게 되었다. rufus 오류 미디어를 열 수 없습니다. 이런 오류를 뿜으면서 자꾸 안된다. ...
-
타입스크립트 관련 이유없이 빨간줄이간다. 설정과 관련이 있는데 tsconfig.json이나 systemjs.config.js 에서 experimentalDecorators: true 설정을넣어줘도 안없어진다. 비쥬얼 스튜디오 코드 설...
-
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) Posted on 22/04/2015 by Admin | Leave ...
댓글 없음:
댓글 쓰기