我正在尝试使用 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);}@Beanpublic 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
1 回答
慕森卡
TA贡献1806条经验 获得超8个赞
修复你的ResourceServerConfig类。使用下面的代码
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
代替
public class ResourceServerConfig {
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
添加回答
举报
0/150
提交
取消