I'm working on one project with Spring 4.2.4.RELEASE.
I've heard about new features Spring 4 (especially about autowiring of generic types ), and I was confused when the following code hadn't been compiled:
@Service
public interface AuthenticationService<T> { ... }
public class VKAuthenticationService implements AuthenticationService<VKToken> { ... }
@RestController
public class VKAuthenticationController {
@Autowired
private AuthenticationService<VKToken> service;
}
Thank you in advance for any assistance.
How about also declare @Service
on your VKAuthenticationService
@Service(name="myService")
public class VKAuthenticationService implements AuthenticationService<VKToken> { ... }
and use @Autowired
and @Qualifier
to inject it
@RestController
public class VKAuthenticationController {
@Autowired
@Qualifier("myService")
private AuthenticationService<VKToken> service;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.