Closed
Description
Yanming Zhou opened SPR-12636 and commented
public interface UserService
public boolean exists(String username);
}
@Component
@Order(1)
public class UserService1 implements UserService {
@Transactional
public boolean exists(String username) {
return false;
}
}
@Component
@Order(2)
public class UserService2 implements UserService {
public boolean exists(String username) {
return false;
}
}
@Autowired
private List<UserService> userServices;
userServices will be [userService1,userService2] when proxyTargetClass=true ,
[userService2,userService1] when proxyTargetClass=false.
If JDK proxy cannot obtain @Order
, I suggest spring use proxyTargetClass=true as default.
Issue Links:
- No way to retrieve the actual target type using beanName [SPR-12704] #17301 No way to retrieve the actual target type using beanName ("depends on")
- Document common use cases for @Order vs @Priority vs @DependsOn [SPR-16213] #20761 Document common use cases for
@Order
vs@Priority
vs@DependsOn
Referenced from: commits 1aec6a6