【发布时间】:2020-03-20 17:37:23
【问题描述】:
我正在尝试从 Spring 应用程序在“ride”表中创建一个新行,我收到以下错误
{
org.springframework.web.client.HttpServerErrorException: 500 null
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:94)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
at org.springframework.web.client.RestTemplate.put(RestTemplate.java:432)
at com.pluralsight.controller.RestControllerTest.testCreateRide(RestControllerTest.java:24)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:834)
}
我使用rest模板将信息添加到mysql表中,如下所示:
RestTemplate restTemplate = new RestTemplate();
Ride ride = new Ride();
ride.setName("Bobsled Trail");
ride.setDuration(33);
restTemplate.put("http://localhost:8080/ride_tracker/ride", ride);
System.out.println("Ride: " + ride);
项目中的所有代码都可以在以下链接中找到: https://github.com/roscasend/ride_tracker
最好的问候, 奥勒良
【问题讨论】:
-
检查你的类'RideRepositoryImpl.java'第43行
标签: mysql spring spring-jdbc jdbctemplate