问题描述
我想从 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 (将#修改为@)