我正在尝试使用 OAuth 设置用户和身份验证。我所有的源代码都在这里: https: //github.com/Incybro/Spring-Blog
我在我的 Intellij IDEA 中安装了 lombok 插件,重新启动了 IDE,但出现了一些错误:
在这一行中:
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
public void save(User user){
user.setPassword(passwordEncoder.encode(user.getPassword()));
repo.save(user);
}
@Bean
public CommandLineRunner setupDefaultUser(UserService service) {
return args -> {
service.save(new User(
"user", //username
"user", //password
Arrays.asList(new Role("USER"), new Role("ACTUATOR")),//roles
true//Active
));
};
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return repo
.findByUsername(username)
.map(u -> new org.springframework.security.core.userdetails.User(
u.getUsername(),
u.getPassword(),
u.isActive(),
u.isActive(),
u.isActive(),
u.isActive(),
AuthorityUtils.createAuthorityList(
u.getRoles()
.stream()
.map(r -> "ROLE_" + r.getName().toUpperCase())
.collect(Collectors.toList())
.toArray(new String[]{}))))
.orElseThrow(() -> new UsernameNotFoundException("No user with "
+ "the name " + username + "was found in the database"));
}
}
没有任何东西被标记为红色。我无法启动我的应用程序。源代码复制自https://www.youtube.com/watch?v=IOgCMtYMr2Q&list=PLcoE64orFoVsxAam_BuQBrNC8IO238SwH&index=2
慕森卡
相关分类