错误代码:
2020-05-28 11:10:31.596 INFO 10112 --- [ main] com.java.discuss.DiscussStart : Starting DiscussStart on DESKTOP-QHHJNFQ with PID 10112 (D:\Java\softJavaWorking\U4\Discuss\target\classes started by tmyue in D:\Java\softJavaWorking\U4\Discuss)
2020-05-28 11:10:31.601 INFO 10112 --- [ main] com.java.discuss.DiscussStart : No active profile set, falling back to default profiles: default
2020-05-28 11:10:31.654 INFO 10112 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1b06cab: startup date [Thu May 28 11:10:31 CST 2020]; root of context hierarchy
2020-05-28 11:10:33.058 INFO 10112 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2020-05-28 11:10:33.059 INFO 10112 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:27017 to client view of cluster
2020-05-28 11:10:33.107 INFO 10112 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:22}] to localhost:27017
2020-05-28 11:10:33.109 INFO 10112 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 6]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=1274800}
2020-05-28 11:10:33.110 INFO 10112 --- [localhost:27017] org.mongodb.driver.cluster : Discovered cluster type of STANDALONE
2020-05-28 11:10:33.321 INFO 10112 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2020-05-28 11:10:33.340 INFO 10112 --- [ main] com.java.discuss.DiscussStart : Started DiscussStart in 2.155 seconds (JVM running for 3.001)
2020-05-28 11:10:33.344 INFO 10112 --- [ Thread-6] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1b06cab: startup date [Thu May 28 11:10:31 CST 2020]; root of context hierarchy
2020-05-28 11:10:33.348 INFO 10112 --- [ Thread-6] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
解决:添加web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>