springboot rest API返回XML响应



我有一个springboot rest api。它工作得很好,但我必须添加一些依赖于它,导致它开始返回响应在Xml而不是JSON。我有其他微服务返回json响应,我没有做任何有意识地返回XML。我需要JSON响应。有人能帮忙吗?

如果有帮助的话,我在gradle文件中包含了我的依赖项。

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
// https://mvnrepository.com/artifact/org.modelmapper/modelmapper
implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.0.0'
// https://jmaven.com/dependency/org.springframework.boot/spring-boot-starter-validation
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-amqp'
// implementation 'org.springframework.cloud:spring-cloud-starter-config'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation group: 'com.google.code.gson', name: 'gson', version: '2.7'
// https://mvnrepository.com/artifact/org.hashids/hashids
implementation group: 'org.hashids', name: 'hashids', version: '1.0.3'
// https://mvnrepository.com/artifact/joda-time/joda-time
//implementation group: 'joda-time', name: 'joda-time', version: '2.3'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2',
// Uncomment the next line if you want to use RSASSA-PSS (PS256, PS384, PS512) algorithms:
//'org.bouncycastle:bcprov-jdk15on:1.60',
'io.jsonwebtoken:jjwt-jackson:0.11.2'
// https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter
implementation 'io.springfox:springfox-boot-starter:3.0.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
//runtimeOnly 'mysql:mysql-connector-java'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
// https://mvnrepository.com/artifact/commons-validator/commons-validator
implementation group: 'commons-validator', name: 'commons-validator', version: '1.7'
// https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber
implementation group: 'com.googlecode.libphonenumber', name: 'libphonenumber', version: '8.12.45'
// https://mvnrepository.com/artifact/javax.mail/mail
implementation group: 'javax.mail', name: 'mail', version: '1.5.0-b01'
// https://mvnrepository.com/artifact/org.apache.commons/commons-io
implementation group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
// https://mvnrepository.com/artifact/com.mandrillapp.wrapper.lutung/lutung
//implementation group: 'com.mandrillapp.wrapper.lutung', name: 'lutung', version: '0.0.8'
// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk
implementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.180'
// https://mvnrepository.com/artifact/com.twilio.sdk/twilio
// https://www.twilio.com/docs/libraries/java
implementation group: "com.twilio.sdk", name: "twilio", version: "8.29.1"
//implementation 'org.springframework.boot:spring-boot-starter-quartz'
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-openfeign
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:3.1.1'
//implementation 'org.springframework.cloud:spring-cloud-openfeign-dependencies:3.1.1'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

这是由于Twilio库删除了该库,并使用HTTP rest调用来使用Twilio api将解决这个问题。

最新更新