“Failed to introspect Class [org.springframework.security. config.annotation. web.configuration. WebSecurityConfiguration]”

How To Fix “Failed to introspect Class [org.springframework.security.config.annotation. web.configuration.WebSecurityConfiguration]”

When you build a Spring Boot project with Maven, you may encounter the “Failed to introspect Class [org.springframework.security.config. annotation.web.configuration. WebSecurityConfiguration]” error. We will show you how to fix it.

The “Failed to introspect Class [org.springframework.security. config.annotation.web.configuration. WebSecurityConfiguration]” Error

This error occurs when you build and run a Spring Boot application with Maven – a popular build automation tool for Java projects. In particular, you use the WebSecurityConfiguration class to secure your application. You may see a screen full of errors, including this line:

Failed to introspect Class [org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration]

Spring Boot, which aims to create production-ready applications out of the box, comes with an embedded Tomcat build by default. You can override it, but this web container can allow you to easily run Java Servlets and other web-based applications. When a Spring MVC controller is detected, Spring Boot will start up a Tomcat instance automatically with all the default configurations required to make it work.

You can also manually add it to the Project Object Model (POM) file when you build your Spring Boot with Maven, however. You can do this by adding the spring-boot-starter-tomcat entry to your POM.xml file. This is a good idea when you want to explicitly specify this web container as a dependency of your project.

But you may run into errors if your POM.xml file has the provided scope for spring-boot-starter-tomcat:


You should be aware of the role of this dependency scope. Maven uses it to limit a dependency’s transitivity and determine when it is included in a Java classpath.

There are 6 scopes in Maven: compile, provided, runtime, test, system, and import.

The default scope is compile, and Maven will use it when you don’t specify any scope for a dependency. When a dependency has this scope, Maven will compile it in all classpaths of your project as well as propagate it to all the dependent projects.

On the other hand, the runtime scope tells Maven that the compilation doesn’t require your dependency and is only needed for execution. Maven will include that dependency in the test and runtime classpaths, not the compile classpath.

When you give spring-boot-starter-tomcat the provided scope, you are basically telling Maven you expect a container or JDK to provide it at runtime. As a result, Maven will only include the dependency in the test and compilation classpaths, not the runtime one.

The absence of spring-boot-starter-tomcat in the runtime classpath can cause some problems, especially when your JDK doesn’t provide it, including the error you have run into. Remove the scope line in the <dependency> entry of spring-boot-starter-tomcat should get rid of it:


You can then run Maven and invoke the compile or install goal:

mvn compile # execute the compile goal

mvn install # compile and package your project


The “Failed to introspect Class [org.springframework.security.config. annotation.web.configuration. WebSecurityConfiguration]” error may happen when you set the wrong Maven dependency scope for Spring Boot Starter Tomcat in your project. Reset it to the default value, and you should be able to compile it successfully again.

Maybe you are interested:

Leave a Reply

Your email address will not be published. Required fields are marked *