Meu controller: @RestController @RequestMapping("/login") public class AutenticacaoController {
@Autowired
private AuthenticationManager manager;
@PostMapping
public ResponseEntity login(@RequestBody @Valid DadosAutenticacao dados){
var authentication = manager.authenticate(token);
}
}
Estou tendo o seguinte problema: Could not autowire. No beans of 'AuthenticationManager' type found.
Cheguei a pesquisar um pouco, tentei algumas soluções envolvendo:
- Herdar a classe: WebSecurityConfigurerAdapter - mas parece que ela está depreciada, nem chega a aparecer para mim, então não consegui testar os métodos envolvendo ela...
Por via das dúvidas, irei colocar minhas dependências, caso seja um problema de versão.
- Dependências:
4.0.0
org.springframework.boot
spring-boot-starter-parent
3.1.4
med.voll
api
0.0.1-SNAPSHOT
api
API Rest da aplicação Voll.med
17
org.springframework.boot
spring-boot-starter-web
org.springframework.boot spring-boot-maven-plugin org.projectlombok lombok<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> </dependency> <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-mysql</artifactId> </dependency> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency>
Meu SecurityConfigurations: @Configuration @EnableWebSecurity public class SecurityConfigurations {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http.csrf(csrf -> csrf.disable())
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.build();
}
}