I have a small Spring / Scala app that is using Autowiring to inject dependencies. The relevant injection declaration is:
@Inject
var userRepo:UserRepository = _
If I declare the interface in Java everything works great:
@Transactional(readOnly = true)
public interface UserRepository extends JpaRepository<User,Long>{
}
The same interface declared as a Scala trait causes Spring to throw BeanCreationException (long stack trace omitted):
@Transactional(readOnly = true)
trait UserRepositoryXX extends JpaRepository[User,java.lang.Long] {
}
I gather this something to do with Spring's inability to create a proxy object for the scala trait? I understand that scala traits are not 100% the same as a Java interface.
My question: Is there a workaround for this issue - or do I need to use Java interfaces?
Thanks
Warren