先看看启动完整的异常:
2021-03-07 19:11:22.118 INFO 3195 --- [ restartedMain] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2021-03-07 19:11:22.153 INFO 3195 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-03-07 19:11:22.494 INFO 3195 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-03-07 19:11:22.513 INFO 3195 --- [ restartedMain] com.example.demo.DemoApplication : Started DemoApplication in 0.612 seconds (JVM running for 1.065)
这里我是使用 idea 创建了一个Spring Boot demo 代码然后进行启动,但是启动就出现了这个问题,经过查询 问题就在上面的那个 没有默认配置的启动容器的意思?
由于我们没有加入 web 依赖所以启动的时候,加载不到启动的容器导致的错误,在pom.xml文件中加入 以下依赖就解决这个问题了:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
再次启动,就启动成功了。