admin管理员组文章数量:1122832
I'm sending the following request:
POST http://localhost:8080/bookings/newBooking
Content-Type: application/json
{
"bookingId": 1,
"user": {
"userId": 3,
"username": "user1",
"password": "password1",
"email": "[email protected]"
},
"paymentId": 4
}
And I get the following error
"org.springframework.web.servlet.resource.NoResourceFoundException: No static resource bookings/newBooking. org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:585).springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:52)...
BookingController:
package org.soa.booking;
@RestController
@RequestMapping("/bookings")
public class BookingController {
private final BookingService bookingService;
@Autowired
public BookingController(BookingService bookingService) {
this.bookingService = bookingService;
}
@PostMapping("/newBooking")
public Booking createBooking(@RequestBody Booking booking) {
return bookingService.createBooking(booking);
}
}
SoaApplication:
package org.soa;
@SpringBootApplication
@RestController
public class SoaApplication {
public static void main(String[] args){
SpringApplication.run(SoaApplication.class, args);
}
build.gradle:
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'
}
group = 'org.soa'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'javax.persistence:javax.persistence-api:2.2'
implementation 'org.mariadb.jdbc:mariadb-java-client:3.0.5'
}
sourceSets {
main {
java {
exclude 'org/soa/passenger/**'
exclude 'org/soa/flight/**'
exclude 'org/soa/payment/**'
exclude 'org/soa/airport/**'
}
}
}
tasks.named('test') {
useJUnitPlatform()
}
From what I understand is that the Controller is being treated as a request for a static resource rather than being handled by the Controller. However, I don't know how to solve it, any insights highly appreciate it.
本文标签: springspringframeworkwebservletresourceNoResourceFoundException No static resourceStack Overflow
版权声明:本文标题:spring - springframework.web.servlet.resource.NoResourceFoundException: No static resource - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300550a1930856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论