<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mauroreinehr</title>
    <description>The latest articles on DEV Community by mauroreinehr (@mauroreinehr).</description>
    <link>https://dev.to/mauroreinehr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F891905%2F60c3cc94-3407-4c80-b5e6-9a420af674fa.png</url>
      <title>DEV Community: mauroreinehr</title>
      <link>https://dev.to/mauroreinehr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mauroreinehr"/>
    <language>en</language>
    <item>
      <title>Problems Starting Spring Boot Application</title>
      <dc:creator>mauroreinehr</dc:creator>
      <pubDate>Thu, 14 Jul 2022 12:00:49 +0000</pubDate>
      <link>https://dev.to/mauroreinehr/problems-starting-spring-boot-application-3mim</link>
      <guid>https://dev.to/mauroreinehr/problems-starting-spring-boot-application-3mim</guid>
      <description>&lt;p&gt;I'm trying to configure Token authentication in Spring Boot 2.7.1 with the following setting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Configuration
@RequiredArgsConstructor
@EnableWebSecurity
public class SecurityConfig {
    @Autowired
    private UserService userService;

    @Autowired
    private AuthEntryPointJwt unauthorizedHandler;

    @Bean
    AuthTokenFilter authenticationJwtTokenFilter() {
        return new AuthTokenFilter();
    }

    @Bean
    UserDetailsService userDetailsService() {
        return userService;
    }

    @Bean
    AuthenticationManager authenticationManager(AuthenticationManagerBuilder builder, PasswordEncoder encoder)
            throws Exception {
        return builder.userDetailsService(userService).passwordEncoder(encoder).and().build();
    }

    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.cors().and().csrf().disable().exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests()
                .antMatchers("/api/v1/auth/**").permitAll().antMatchers("/api/v1/test/**").permitAll().anyRequest()
                .authenticated();

        http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);

        return http.build();
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But when I start the application, you are getting the following error:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': &lt;strong&gt;Unsatisfied dependency expressed through method 'setFilterChains' parameter 0&lt;/strong&gt;; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultSecurityFilterChain' defined in class path resource [org/springframework/boot/autoconfigure/security/servlet/SpringBootWebSecurityConfiguration$SecurityFilterChainConfiguration.class]: Unsatisfied dependency expressed through method 'defaultSecurityFilterChain' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.HttpSecurityConfiguration.httpSecurity' defined in class path resource [org/springframework/security/config/annotation/web/configuration/HttpSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.config.annotation.web.builders.HttpSecurity]: Factory method 'httpSecurity' threw exception; nested exception is java.lang.IllegalStateException: Cannot apply org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration$EnableGlobalAuthenticationAutowiredConfigurer@194e1965 &lt;strong&gt;to already built object&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>security</category>
    </item>
  </channel>
</rss>
