错误信息:
D:\Java\corretto-1.8.0_342\bin\java.exe -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 -javaagent:D:\IDEA\apps\IDEA-U\ch-0\222.4345.14\lib\idea_rt.jar=54850
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.2)
2022-11-01 09:19:00 [INFO] org.springframework.boot.StartupInfoLogger:48 : Starting ApplicationKt on OAK with PID 20788 (E:\Project-Code\OutsideApi\build\classes\kotlin\main started by DELL in E:\Project-Code\OutsideApi)
2022-11-01 09:19:00 [INFO] org.springframework.boot.SpringApplication:593 : No active profile set, falling back to default profiles: default
2022-11-01 09:19:00 [INFO] org.springframework.context.support.AbstractApplicationContext:583 : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7ee955a8: startup date [Tue Nov 01 09:19:00 CST 2022]; root of context hierarchy
2022-11-01 09:19:01 [INFO] org.springframework.jmx.export.MBeanExporter:431 : Registering beans for JMX exposure on startup
2022-11-01 09:19:01 [INFO] org.springframework.boot.StartupInfoLogger:57 : Started JoySpaceApplicationKt in 1.018 seconds (JVM running for 1.513)
2022-11-01 09:19:01 [INFO] org.springframework.context.support.AbstractApplicationContext:984 : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7ee955a8: startup date [Tue Nov 01 09:19:00 CST 2022]; root of context hierarchy
2022-11-01 09:19:01 [INFO] org.springframework.jmx.export.MBeanExporter:449 : Unregistering JMX-exposed beans on shutdown
Process finished with exit code 0
网上的解决方案:
引入Tomcat
implementation("org.springframework.boot:spring-boot-starter-tomcat:2.7.2")
启动成功
,结果又会出现另一个问题,访问所有接口都变成404
HTTP/1.1 404
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1086
Date: Tue, 01 Nov 2022 01:28:17 GMT
<!doctype html>
<html lang="en">
<head><title>HTTP Status 404 – Not Found</title>
<style type="text/css">h1 {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
font-size: 22px;
}
h2 {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
font-size: 16px;
}
h3 {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
font-size: 14px;
}
body {
font-family: Tahoma, Arial, sans-serif;
color: black;
background-color: white;
}
b {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
}
p {
font-family: Tahoma, Arial, sans-serif;
background: white;
color: black;
font-size: 12px;
}
a {
color: black;
}
a.name {
color: black;
}
.line {
height: 1px;
background-color: #525D76;
border: none;
}</style>
</head>
<body><h1>HTTP Status 404 – Not Found</h1>
<hr class="line"/>
<p><b>Type</b> Status Report</p>
<p><b>Message</b> /photo/takeCutPic</p>
<p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing
to disclose that one exists.</p>
<hr class="line"/>
<h3>Apache Tomcat/8.5.23</h3></body>
</html>
Response file saved.
> 2022-11-01T092817.404.html
Response code: 404; Time: 42ms (42 ms); Content length: 1082 bytes (1.08 kB)
完美解决方案:
缺失: org.springframework.boot:spring-boot-starter-web:2.7.2
依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
implementation("org.springframework.boot:spring-boot-starter-web:2.7.2")
结语
如果这篇文章对您有所帮助,或者有所启发的话,求一键三连:点赞、评论、收藏➕关注,您的支持是我坚持写作最大的动力。