如果我正确实施了 OAuth 2.0 授权,我将尝试使用 Postman 测试它。我正在通过邮递员发送这个期待令牌作为回报http://localhost:8080/oauth/token/grant_type=password&username=user&password=user但是我在这部分代码中有错误:@SpringBootApplicationpublic class KamehouseApplication { public static void main(String[] args) { SpringApplication.run(KamehouseApplication.class, args); } @Autowired public void configure(AuthenticationManagerBuilder auth, UserRepository repo, User user) throws Exception { if (repo.count() == 0) user = (new User("user", // username "user", // password Arrays.asList(new Role("USER"), new Role("ACTUATOR"))));// roles repo.save(user); auth.userDetailsService(s -> new CustomUserDetails(repo.findByUsername(s))); }}红色下划线的部分是Arrays.asList(new Role("USER"), new Role("ACTUATOR"))));说The method asList(T...) in the type Arrays is not applicable for the arguments (Role, Role)这是我的用户类@Entity@Table(name = "user")public class User { @Id @GeneratedValue public int id; public String firstname; public String lastname; public String username; public String password; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) private List<Role> roles; public User() { } //Getters/Setters
添加回答
举报
0/150
提交
取消