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.