Кто-нибудь может мне помочь с этой ошибкой?
org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; bad SQL grammar [select username,password,enabled from users where username = ?]; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'enabled' in 'field list'
Когда я вхожу в систему, я ввожу правильный логин и пароль из MySQL БД. Я даже не использую шифрование своего пароля и даже не использую столбец «включен» в моей БД.
Мне поможет любой учебник или предложение. Спасибо, ребята!
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
// add a reference to our security data source
@Autowired
@Qualifier("appDataSource")
private DataSource appDataSource;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// use jdbc authentication ... oh yeah!!!
auth.jdbcAuthentication().dataSource(appDataSource);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/", "index", "/resources/**", "/css/**", "/js/**", "/image/**","/templates/**").permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/authenticateCredentials")
.defaultSuccessUrl("/")
.and()
.logout()
.logoutSuccessUrl("/login") // after logout redirect to landing page (root)
.permitAll()
.and()
.exceptionHandling().accessDeniedPage("/access-denied");
}
}
@Controller
@RequestMapping("/users")
public class UserController {
private UserService userService;
@Autowired
public UserController (UserService userService){
this.userService = userService;
}
@PostMapping("/add")
public String addEmployee(@ModelAttribute("user") User user) {
//add user
this.userService.save(user);
return "redirect:/index.html";
}
}