使用Mac Idea創建springBoot工程,創建完畢啓動日誌如下:
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -XX:TieredStopAtLevel=1 -noverify-
Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -
Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath
加載各種****.jar包
com.monkey.yb.springdemo.SpringdemoApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.8.RELEASE)
2019-09-10 10:08:50.961 INFO 648 --- [ main] c.m.yb.springdemo.SpringdemoApplication : Starting SpringdemoApplication on zhujunfengdeMacBook-Pro.local with PID 648
2019-09-10 10:08:50.963 INFO 648 --- [main] c.m.yb.springdemo.SpringdemoApplication : No active profile set, falling back to default profiles: default
2019-09-10 10:08:51.324 INFO 648 --- [main] c.m.yb.springdemo.SpringdemoApplication : Started SpringdemoApplication in 15.609 seconds (JVM running for 21.159)
Process finished with exit code 0
此問題產生的原因是缺少springBoot-web依賴,在pom.xml文件中添加spring-boot-starter-web即可,如下:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>