javax.servlet.servletexception cannot be resolved. it is indirectly referenced from required .class files code example

Example 1: the type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from required .class files

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

Example 2: the type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from required .class files

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
</dependency>

Tags:

Java Example