我有一个 REST 控制器,我在其中编写了此代码
@PostMapping(value = "/otp")
public void otp(@RequestBody Integer mobile) {
System.out.println(" Mobile = "+mobile);
}
Run Code Online (Sandbox Code Playgroud)
我使用以下输入从 Postman 调用此方法
URL : localhost:8080/otp
Body :
{
"mobile":123456
}
Run Code Online (Sandbox Code Playgroud)
但我收到以下异常
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not deserialize instance of java.lang.Integer out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token
Run Code Online (Sandbox Code Playgroud)
如果我将 String 作为这样的参数
@PostMapping(value = "/otp")
public void otp(@RequestBody String mobile) {
System.out.println(" Mobile = "+mobile);
}
Run Code Online (Sandbox Code Playgroud)
并将输入作为
{
"mobile":123456
}
Run Code Online (Sandbox Code Playgroud)
现在它在控制台中打印如下
Mobile …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring Boot 使用 SOAP Web 服务。要将 WSDL 转换为 Java 绑定(域)类,我正在使用maven-jaxb2-plugin.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<generatePackage>com.test.consume</generatePackage>
<schemas>
<schema>
<url>https://test.co.in/cordys/WSDLGateway.wcp?service=http://schemas.cordys.com/default/getIDV&organization=o=B2C,cn=cordys,cn=defaultInst106,o=mydomain.com</url>
</schema>
</schemas>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在
<url>标签中我写了这样的 WSDL URL
<url>https://test.co.in/cordys/WSDLGateway.wcp?service=http://schemas.cordys.com/default/getIDV&organization=o=B2C,cn=cordys,cn=defaultInst106,o=mydomain.com</url>
Run Code Online (Sandbox Code Playgroud)
但是我在 pom.xml 中遇到了以下问题
Project build error: Non-parseable POM /home/altaf/My Workspace/TestConsumer/pom.xml: entity reference name can not contain character
=' (position: START_TAG seen ...wcp?service=http://schemas.cordys.com/default/getIDV&organization=... @64:117)
如何解决这个问题?