Solucionado (ver solução)
Solucionado
(ver solução)
15
respostas

The constructor Date(String) is deprecated

public String gerarToken(Authentication authentication) { Usuario logado = (Usuario) authentication.getPrincipal(); Date hoje = new Date(); Date dataExpiracao = new Date(hoje.getTime() + expiration); =>The constructor Date(String) is deprecatedJ apareceu esse erro quando coloquei esse comando Date(hoje.getTime() + expiration)

15 respostas

2022-05-03 15:20:46.677 INFO 12656 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 15:20:44.372 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@2bd5fb68

. __ _ __ _ _ /\ / _'_ _ _ _()_ _ __ _ \ \ \ ( ( )___ | ' | '| | ' / ` | \ \ \ \/ ___)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||_| |_, | / / / / =========||==============|__/=//// :: Spring Boot :: (v2.6.6)

2022-05-03 15:20:44.965 INFO 12656 --- [ restartedMain] br.com.alura.forum.ForumApplication : Starting ForumApplication using Java 18 on NB110112 with PID 12656 (C:\Users\joao.pereira\Documents\forum\forum\target\classes started by joao.pereira in c:\Users\joao.pereira\Documents\forum\forum) 2022-05-03 15:20:44.967 INFO 12656 --- [ restartedMain] br.com.alura.forum.ForumApplication : No active profile set, falling back to 1 default profile: "default" 2022-05-03 15:20:45.149 INFO 12656 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2022-05-03 15:20:45.149 INFO 12656 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2022-05-03 15:20:46.793 INFO 12656 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 95 ms. Found 3 JPA repository interfaces. 2022-05-03 15:20:48.291 INFO 12656 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-05-03 15:20:48.308 INFO 12656 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-05-03 15:20:48.309 INFO 12656 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60] 2022-05-03 15:20:48.500 INFO 12656 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-05-03 15:20:48.500 INFO 12656 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3349 ms 2022-05-03 15:20:48.618 INFO 12656 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2022-05-03 15:20:48.873 INFO 12656 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2022-05-03 15:20:48.902 INFO 12656 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:alura-forum' 2022-05-03 15:20:49.180 INFO 12656 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-05-03 15:20:49.318 INFO 12656 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.7.Final 2022-05-03 15:20:49.595 INFO 12656 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-05-03 15:20:49.812 INFO 12656 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect Hibernate:

create table curso (
   id bigint generated by default as identity,
    categoria varchar(255),
    nome varchar(255),
    primary key (id)
)

Hibernate:

create table perfil (
   id bigint generated by default as identity,
    nome varchar(255),
    primary key (id)
)

Hibernate:create table resposta ( id bigint generated by default as identity, data_criacao timestamp, mensagem varchar(255), solucao boolean, autor_id bigint, topico_id bigint, primary key (id) ) Hibernate:

create table topico (
   id bigint generated by default as identity,
    data_criacao timestamp,
    mensagem varchar(255),
    status varchar(255),
    titulo varchar(255),
    autor_id bigint,
    curso_id bigint,
    primary key (id)
)

Hibernate:

create table usuario (
   id bigint generated by default as identity,
    email varchar(255),
    nome varchar(255),
    senha varchar(255),
    primary key (id)
)

Hibernate:

create table usuario_perfis (
   usuario_id bigint not null,
    perfis_id bigint not null
)

Hibernate:

alter table resposta 
   add constraint FK9999kvnmdq63ah7imctrl06r7 
   foreign key (autor_id) 
   references usuario

Hibernate:

alter table resposta 
   add constraint FKltuv9rkfjtlmn8b0rb3wdbjsv 
   foreign key (topico_id) 
   references topico

Hibernate:

alter table topico 
   add constraint FKsk04hscorwqdymnafg8882v64 
   foreign key (autor_id) 
   references usuario

Hibernate:

alter table topico 
   add constraint FKcaaogjo0ynd54updie6kdpxd1 
   foreign key (curso_id) 
   references curso

Hibernate:

alter table usuario_perfis 
   add constraint FK7bhs80brgvo80vhme3u8m6ive 
   foreign key (perfis_id) 
   references perfil

Hibernate:

alter table usuario_perfis 
   add constraint FKs91tgiyagbilt959wbufiphgc 
   foreign key (usuario_id) 
   references usuario
   2022-05-03 15:20:51.080  INFO 12656 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'

2022-05-03 15:20:51.708 WARN 12656 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2022-05-03 15:20:51.756 WARN 12656 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'autenticacaoController': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 2022-05-03 15:20:51.757 INFO 12656 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2022-05-03 15:20:51.976 WARN 12656 --- [ restartedMain] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200] 2022-05-03 15:20:51.976 INFO 12656 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2022-05-03 15:20:51.981 INFO 12656 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. 2022-05-03 15:20:51.984 INFO 12656 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2022-05-03 15:20:52.001 INFO 12656 --- [ restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2022-05-03 15:20:52.047 ERROR 12656 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Field authManager in br.com.alura.forum.controller.AutenticacaoController required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.

The injection point has the following annotations:

- @org.springframework.beans.factory.annotation.Autowired(required=true)

2

Action: Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.

As postagens anteriores e o erro que apareceu no console

Oi João,

A princípio são 2 questões:

  1. The constructor Date(String) is deprecated -> Não tem problema usar esse construtor deprecated. Não vai interferir no projeto
  2. AutenticacaoController required a bean of type 'org.springframework.security.authentication.AuthenticationManager -> Confere na sua classe SecurityConfigurations se você criou o método authenticationManager, conforme demonstrado no início desse vídeo: https://cursos.alura.com.br/course/spring-boot-seguranca-cache-monitoramento/task/55846

package br.com.alura.forum.config.validacao.security;

import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@EnableWebSecurity @Configuration public class SecurityConfigurations extends WebSecurityConfigurerAdapter {

 @Autowired
 private AutenticacaoService autenticacaoService;

 protected AuthenticationManager authenticationManager() throws Exception {
      return super.authenticationManager();
 }

 //Configurações de autenticação
 @Override
 @Bean
 protected void configure(AuthenticationManagerBuilder auth) throws Exception{
      auth.userDetailsService(autenticacaoService).passwordEncoder(new BCryptPasswordEncoder());
 }

 //Configurações de autorização
 @Override
 protected void configure(HttpSecurity http) throws Exception{ 
      http.authorizeRequests()
      .antMatchers(HttpMethod.GET, "/topicos").permitAll()
      .antMatchers(HttpMethod.GET, "/topicos/*").permitAll()
      .antMatchers(HttpMethod.POST,"/auth").permitAll()
      .anyRequest().authenticated()
      .and().csrf().disable()
      .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);   
 }

 //Configuraçõs de recursos estáticos(js, css, img, etc.)
 @Override
 public void configure(WebSecurity web) throws Exception{         
 }

}

Faltou o @Bean no método.

Precisa colocar em todos os @Override

Somente no método authenticationManager(). Os outros não são métodos que estão devolvendo objetos para o Spring.

APARECEU ESSE ERRO NO CONSOLE AGORA 2022-05-04 08:32:38.020 INFO 11800 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 08:32:37.318 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@40019fe1

. __ _ __ _ _ /\ / _'_ _ _ _()_ _ __ _ \ \ \ ( ( )___ | ' | '| | ' / ` | \ \ \ \/ ___)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||_| |_, | / / / / =========||==============|__/=//// :: Spring Boot :: (v2.6.6)

2022-05-04 08:32:37.859 INFO 11800 --- [ restartedMain] br.com.alura.forum.ForumApplication : Starting ForumApplication using Java 18 on NB110112 with PID 11800 (C:\Users\joao.pereira\Documents\forum\forum\target\classes started by joao.pereira in c:\Users\joao.pereira\Documents\forum\forum) 2022-05-04 08:32:37.862 INFO 11800 --- [ restartedMain] br.com.alura.forum.ForumApplication : No active profile set, falling back to 1 default profile: "default" 2022-05-04 08:32:38.019 INFO 11800 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2022-05-04 08:32:39.352 INFO 11800 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2022-05-04 08:32:39.437 INFO 11800 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 74 ms. Found 3 JPA repository interfaces. 2022-05-04 08:32:40.590 INFO 11800 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-05-04 08:32:40.609 INFO 11800 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-05-04 08:32:40.609 INFO 11800 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60] 2022-05-04 08:32:40.774 INFO 11800 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-05-04 08:32:40.774 INFO 11800 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2751 ms 2022-05-04 08:32:40.832 INFO 11800 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2022-05-04 08:32:41.080 INFO 11800 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2022-05-04 08:32:41.117 INFO 11800 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:alura-forum' 2022-05-04 08:32:41.441 INFO 11800 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-05-04 08:32:41.589 INFO 11800 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.7.Final 2022-05-04 08:32:41.851 INFO 11800 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-05-04 08:32:42.036 INFO 11800 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect Hibernate:

create table curso (
   id bigint generated by default as identity,
    categoria varchar(255),
    nome varchar(255),
    primary key (id)
)

Hibernate:

create table perfil (
   id bigint generated by default as identity,
    nome varchar(255),
    primary key (id)
)

Hibernate:

create table resposta (
   id bigint generated by default as identity,
    data_criacao timestamp,
    mensagem varchar(255),
    solucao boolean,
    autor_id bigint,
    topico_id bigint,
    primary key (id)
)

Hibernate:

create table topico (
   id bigint generated by default as identity,
    data_criacao timestamp,
    mensagem varchar(255),
    status varchar(255),
    titulo varchar(255),
    autor_id bigint,
    curso_id bigint,
    primary key (id)
)

Hibernate:

create table usuario (
   id bigint generated by default as identity,
    email varchar(255),
    nome varchar(255),
    senha varchar(255),
    primary key (id)
)

Hibernate:

create table usuario_perfis (
   usuario_id bigint not null,

Hibernate:

alter table resposta 
   add constraint FKltuv9rkfjtlmn8b0rb3wdbjsv 
   foreign key (topico_id) 
   references topico

Hibernate:

alter table topico 
   add constraint FKsk04hscorwqdymnafg8882v64 
   foreign key (autor_id) 
   references usuario

Hibernate:

alter table topico 
   add constraint FKcaaogjo0ynd54updie6kdpxd1 
   foreign key (curso_id) 
   references curso

Hibernate:

alter table usuario_perfis 
   add constraint FK7bhs80brgvo80vhme3u8m6ive 
   foreign key (perfis_id) 
   references perfil

Hibernate:

alter table usuario_perfis 
   add constraint FKs91tgiyagbilt959wbufiphgc 
   foreign key (usuario_id) 
   references usuario

2022-05-04 08:32:43.211 INFO 11800 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2022-05-04 08:32:43.223 INFO 11800 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2022-05-04 08:32:43.833 WARN 11800 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2022-05-04 08:32:43.867 WARN 11800 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'autenticacaoController': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationManager]: Factory method 'authenticationManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configure' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Invalid factory method 'configure' on class [br.com.alura.forum.config.validacao.security.SecurityConfigurations]: needs to have a non-void return type! 2022-05-04 08:32:43.867 INFO 11800 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2022-05-04 08:32:44.096 WARN 11800 --- [ restartedMain] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200] 2022-05-04 08:32:44.096 INFO 11800 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2022-05-04 08:32:44.096 INFO 11800 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. 2022-05-04 08:32:44.113 INFO 11800 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2022-05-04 08:32:44.153 INFO 11800 --- [ restartedMain] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2022-05-04 08:32:44.209 ERROR 11800 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'autenticacaoController': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationManager]: Factory method 'authenticationManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configure' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Invalid factory method 'configure' on class [br.com.alura.forum.config.validacao.security.SecurityConfigurations]: needs to have a non-void return type! at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.18.jar:5.3.18] AutowiredAnnotationBeanPostProcessor.java:659 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.18.jar:5.3.18] AutowiredAnnotationBeanPostProcessor.java:639 at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.18.jar:5.3.18] InjectionMetadata.java:119 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.18.jar:5.3.18] AutowiredAnnotationBeanPostProcessor.java:399 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1431 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:619 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] DefaultSingletonBeanRegistry.java:234 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:333 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:208 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.18.jar:5.3.18] DefaultListableBeanFactory.java:953 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.18.jar:5.3.18] AbstractApplicationContext.java:918 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.18.jar:5.3.18] AbstractApplicationContext.java:583 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.6.jar:2.6.6] ServletWebServerApplicationContext.java:145 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:740 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:415 at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:303 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:1301 at br.com.alura.forum.ForumApplication.main(ForumApplication.java:14) ~[classes/:na] ForumApplication.java:14 at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[na:na] DirectMethodHandleAccessor.java:104 at java.base/java.lang.reflect.Method.invoke(Method.java:577) ~[na:na] Method.java:577

at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.6.6.jar:2.6.6] RestartLauncher.java:49 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationManager]: Factory method 'authenticationManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configure' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Invalid factory method 'configure' on class [br.com.alura.forum.config.validacao.security.SecurityConfigurations]: needs to have a non-void return type! at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.18.jar:5.3.18] ConstructorResolver.java:658 at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1352 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1195 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:582 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:542 at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:335 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] DefaultSingletonBeanRegistry.java:234 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:333 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:208 at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.18.jar:5.3.18] DependencyDescriptor.java:276 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.18.jar:5.3.18] DefaultListableBeanFactory.java:1389 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.18.jar:5.3.18] DefaultListableBeanFactory.java:1309 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.18.jar:5.3.18] AutowiredAnnotationBeanPostProcessor.java:656 ... 23 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationManager]: Factory method 'authenticationManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configure' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Invalid factory method 'configure' on class [br.com.alura.forum.config.validacao.security.SecurityConfigurations]: needs to have a non-void return type! at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.18.jar:5.3.18] SimpleInstantiationStrategy.java:185 at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.18.jar:5.3.18] ConstructorResolver.java:653 ... 36 common frames omitted

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configure' defined in class path resource [br/com/alura/forum/config/validacao/security/SecurityConfigurations.class]: Invalid factory method 'configure' on class [br.com.alura.forum.config.validacao.security.SecurityConfigurations]: needs to have a non-void return type! at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:623) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1352 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1195 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:582 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:542 at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:335 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] DefaultSingletonBeanRegistry.java:234 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:333 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:218) ~[spring-beans-5.3.18.jar:5.3.18] AbstractBeanFactory.java:218 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:361) ~[spring-context-5.3.18.jar:5.3.18] ConfigurationClassEnhancer.java:361 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334) ~[spring-context-5.3.18.jar:5.3.18] ConfigurationClassEnhancer.java:334 at br.com.alura.forum.config.validacao.security.SecurityConfigurations$$EnhancerBySpringCGLIB$$721f38fa.configure() ~[classes/:na] at org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.authenticationManager(WebSecurityConfigurerAdapter.java:264) ~[spring-security-config-5.6.2.jar:5.6.2] WebSecurityConfigurerAdapter.java:264 at br.com.alura.forum.config.validacao.security.SecurityConfigurations.authenticationManager(SecurityConfigurations.java:25) ~[classes/:na] SecurityConfigurations.java:25 at br.com.alura.forum.config.validacao.security.SecurityConfigurations$$EnhancerBySpringCGLIB$$721f38fa.CGLIB$authenticationManager$3() ~[classes/:na] at br.com.alura.forum.config.validacao.security.SecurityConfigurations$$EnhancerBySpringCGLIB$$721f38fa$$FastClassBySpringCGLIB$$d29b80df.invoke() ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.18.jar:5.3.18] MethodProxy.java:244 at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.18.jar:5.3.18] ConfigurationClassEnhancer.java:331 at br.com.alura.forum.config.validacao.security.SecurityConfigurations$$EnhancerBySpringCGLIB$$721f38fa.authenticationManager() ~[classes/:na] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[na:na] DirectMethodHandleAccessor.java:104 at java.base/java.lang.reflect.Method.invoke(Method.java:577) ~[na:na] Method.java:577 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.18.jar:5.3.18] SimpleInstantiationStrategy.java:154 ... 37 common frames omitted

Acho que na sua classe de segurança ainda tem outros métodos anotados com @Bean. Somente o método authenticationManager() deve ter essa anotação.

solução!

package br.com.alura.forum.config.validacao.security;

import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@EnableWebSecurity @Configuration public class SecurityConfigurations extends WebSecurityConfigurerAdapter {

 @Autowired
 private AutenticacaoService autenticacaoService;

 protected AuthenticationManager authenticationManager() throws Exception {
      return super.authenticationManager();
 }

 //Configurações de autenticação
 @Override
 @Bean
 protected void configure(AuthenticationManagerBuilder auth) throws Exception{
      auth.userDetailsService(autenticacaoService).passwordEncoder(new BCryptPasswordEncoder());
 }

 //Configurações de autorização
 @Override
 protected void configure(HttpSecurity http) throws Exception{ 
      http.authorizeRequests()
      .antMatchers(HttpMethod.GET, "/topicos").permitAll()
      .antMatchers(HttpMethod.GET, "/topicos/*").permitAll()
      .antMatchers(HttpMethod.POST,"/auth").permitAll()
      .anyRequest().authenticated()
      .and().csrf().disable()
      .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);   
 }

 //Configuraçõs de recursos estáticos(js, css, img, etc.)
 @Override
 public void configure(WebSecurity web) throws Exception{         
 }

}