Spring boot JSP error: NoClassDefFoundError

前端 未结 3 1553
迷失自我
迷失自我 2021-02-08 13:30

Everytime I try to run spring boot app configured with JSP I get this error:

java.lang.NoClassDefFoundError: javax/servlet/ServletContext
    at java.lang.Class.         


        
3条回答
  •  长情又很酷
    2021-02-08 13:46

    There's a bug in IntelliJ that means that provided dependencies aren't added to the classpath. Assuming you want to stick with IDEA, you have a few options:

    • Manually configure the classpath in IDEA
    • Run the samples on the command line using mvn spring-boot:run
    • Remove all occurrences of provided from the pom. This will mean that app can't be deployed as a war to Tomcat or similar

    EDIT: The bug is fixed and the server will start normally, as long as you tick the Include dependencies with "Provided" scope checkbox in the run configuration, below classpath.

提交回复
热议问题