I'm pretty new to Maven and Java itself.
I'm trying to run my project's .jar file that is produced after running :
maven install cleanmaven package
When I run the jar file, I get the following error :
I have tried several solutions online but still cannot make sense of it or how to resolve it. I can edit this question and share my pom.xml file if necessary. this is the dependency version I am using :
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>

Remove the
@Autowiredfrom the httpRequest variable in theApiController, you shouldn't have a bean of typeHttpServletRequest, that's an object that gets created for each request. You can add aHttpServletRequestparameter to any method in your controller class that is annotated to be a HTTP method (@GetMapping) and Spring will automatically initialize the parameter with a reference to the currentHttpServletRequest.Scope
providedmeans that the dependency should be provided at runtime by JDK or a container. You have 2 options:Option 1. Remove the scope:
Option 2. Add the dependency to the classpath:
just be careful that the second option overrides the entire classpath so if you have some other jars in your current folder or elsewhere seperate them with
;.Example:
-classpath .;lib;<path_to_jakarta>this will search in current folder,libsubfolder, and pathOption 3: If you have a web application and use Tomcat keep the
<scope>provided</scope>since those will be included in the classpath automatically by Tomcat.