IntelliJ exception __js of spring boot JSP

Source: Internet
Author: User
Scene Description

The project uses the spring boot to carry on the development with the page, has downloaded the corresponding spring-boot-sample-web-jsp project from the GitHub on the Simples, after the simple modification life and death does not start, all sorts of anomalies. Spring-boot to be simple and easy to use as the core purpose, but why in the introduction of the jar there will be so many problems. Exception Information

Exception One:

2016-06-17 11:04:14.216 ERROR 4684---[           main] o.s.boot.springapplication               : Application startup failed

Java.lang.noclassdeffounderror:javax/servlet/servletcontext at
    Java.lang.Class.getDeclaredMethods0 (Native method) at
    java.lang.Class.privateGetDeclaredMethods (class.java:2531)
    at Java.lang.Class.getDeclaredMethods (class.java:1855)

Obviously, this is not found in the ServletContext class, and, as a result, the whimsical addition of the Servlet-api jar package.
After adding, the exception occurs two:

2016-06-17 11:06:13.860 ERROR 224---[           main] o.s.boot.springapplication               : Application startup failed

Org.springframework.context.ApplicationContextException:Unable to start embedded container; Nested exception is org.springframework.context.ApplicationContextException:Unable to start Embeddedwebapplicationcontext due to missing embeddedservletcontainerfactory bean.

Searching the internet for a variety of this exception solutions did not solve the success. Solution

After many attempts, almost giving up, the sudden thought of a problem could be the result of IntelliJ integration Maven's scope setting when the jar package was introduced.

Examine the Pom file carefully and find that the problem may occur in two places:

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId> spring-boot-starter-tomcat</artifactid>
      <version>1.2.3.RELEASE</version>
      <scope >provided</scope>
    </dependency>
    <dependency>
      <groupId> org.apache.tomcat.embed</groupid>
      <artifactId>tomcat-embed-jasper</artifactId>
      < version>7.0.68</version>
      <scope>provided</scope>
    </dependency>

Comment out of the two configuration

<scope>provided</scope>

The problem is solved. Summary

This may be a bug in IntelliJ, when using Spring-boot, if an introduced dependency is set to provided, the corresponding class will not be found when the IntelliJ is started. Therefore, this configuration should be commented out at this time, but when packaged on the line does not need these dependencies, then in the packaging when the note open, you can.

Have met two times the same question, remember.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.