如何解决是否可以从 Spring Java 8 中的功能接口访问服务类方法?
我想从 Spring Java 8 中的函数式接口访问服务类方法。可以吗?
public interface UserProfile extends supplier<UserProfileDto> {
// This is working
static UserProfile getMyId() {
return () ->
new UserProfileDto(
SecurityContextHolder.getContext().getAuthentication().getName(),"","");
}
static UserProfile getMyProfile() {
return () ->
}
}
@Service("userProfileService")
public class UserProfileServiceImpl implements UserProfileService {
private final UserProfileRepo userProfileRepo;
@Autowired
public UserProfileServiceImpl(@Qualifier("userProfilesql") UserProfileRepo userProfileRepo) {
this.userProfileRepo = userProfileRepo;
}
@Override
public Optional<UserProfileDto> getUserProfileById(String userId) {
return userProfileRepo.selectUserProfileById(userId);
}
}
我想在 UserProfile 的 getMyProfile() 中调用服务类方法“getUserProfileById(SecurityContextHolder.getContext().getAuthentication().getName())”。可能吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。