建项目的步骤:
新建好项目后运行,出错:
_ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2017-09-05 11:25:45.397 INFO 10244 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on admin-PC with PID 10244 (D:\usr\demo\target\classes started by admin in D:\usr\demo)
2017-09-05 11:25:45.399 INFO 10244 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2017-09-05 11:25:45.428 INFO 10244 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@120d6fe6: startup date [Tue Sep 05 11:25:45 CST 2017]; root of context hierarchy
2017-09-05 11:25:45.748 WARN 10244 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-09-05 11:25:45.825 WARN 10244 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-09-05 11:25:45.999 INFO 10244 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-05 11:25:46.008 INFO 10244 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 0.759 seconds (JVM running for 1.246)
2017-09-05 11:25:46.009 INFO 10244 --- [ Thread-4] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@120d6fe6: startup date [Tue Sep 05 11:25:45 CST 2017]; root of context hierarchy
2017-09-05 11:25:46.010 INFO 10244 --- [ Thread-4] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Process finished with exit code 0
解决方法:
需要添加tomcat插件, 还不能有<scope>provided</scope> 添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
然后刷新项目。再次运行: