Search code examples
javamavenintellij-idea

Required type: java.lang.String Provided: java.lang.String


The required and provided data types are the same i.e., java.lang.String then why is this error being shown?

This is my project configuration.

These were the default dependencies in my project. In specifications tab only one depenedency of Servlet (5.0.0) was included.

Given that the required and provided data types are the same, there shouldn't have been any problem. If someone can help it would be really appreciated. Thanks.


Solution

  • In IntelliJ, go to

    File -> Invalidate Caches... -> Invalidate & restart.

    (All checkboxes in "Invalidate Caches" were unchecked, and I just clicked "Invalidate & restart", and it worked for me.)

    IntelliJ restarts and the issue is now fixed. ✅