Я получаю это сообщение об ошибке:
Ошибка: конструктор SecurityProperties.User (String, String, boolean, boolean, boolean, boolean, List) не определен
Это мой код:
package org.launchcode.shopcartsbh.service;
import java.util.ArrayList;
import java.util.List;
import org.launchcode.shopcartsbh.dao.AccountDAO;
import org.launchcode.shopcartsbh.entity.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private AccountDAO accountDAO;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
Account account = accountDAO.findAccount(username);
System.out.println("Account= " + account);
if (account == null) {
throw new UsernameNotFoundException("User " //
+ username + " was not found in the database");
}
// EMPLOYEE,MANAGER,..
String role = account.getUserRole();
List<GrantedAuthority> grantList = new ArrayList<GrantedAuthority>();
// ROLE_EMPLOYEE, ROLE_MANAGER
GrantedAuthority authority = new SimpleGrantedAuthority(role);
grantList.add(authority);
String user = account.getUserName();
String password = account.getEncrytedPassword();
boolean enabled = account.isActive();
boolean accountNonExpired = true;
boolean credentialsNonExpired = true;
boolean accountNonLocked = true;
**** UserDetails userDetails = (UserDetails) new User(user, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, grantList);
**** this is where the error is
return userDetails;
}
}
Мне было интересно, можно ли их переписать, чтобы сделать его более функциональным?Я исследовал это в течение последних нескольких дней, но до сих пор не нашел решения.