4
저는 scala에서 spring을 사용하고 있습니다. trait/superclass로 서비스를 주입하려고 할 때 문제가 있습니다.@Autowired with scala를 사용합니다.
trait MyServiceHolder{
var myService:MyService = null
@Autowired
def setMyService(ms:MyService) = myService = ms
}
@RunWith(classOf[SpringJUnit4ClassRunner])
@ContextConfiguration(Array("file:src/main/webapp/WEB-INF/application-context.xml"))
class MyConcreteClass extends MyServiceHolder{
def hello() = myService.hello()
}
이 작동 :
@RunWith(classOf[SpringJUnit4ClassRunner])
@ContextConfiguration(Array("file:src/main/webapp/WEB-INF/application-context.xml"))
class MyConcreteClass{
var myService:MyService = null
@Autowired
def setMyService(ms:MyService) = myService = ms
def hello() = myService.hello()
}
문제는 myService 내을 testcases의 null이다
이 내 코드입니다. 바이트 코드 레벨 (클래스 파일)을 볼 때 모든 주석이 있습니다. 어떤 아이디어?
junit 러너를 사용하고 있습니다. 그것을 내 코드에 추가했습니다. – MrWhite