我有一个POJO类和一个implementation 'com.android.support:customtabs:28.0.0'
,如下所示:
RestController
Account.java
public class Account {
String name;
String accountId;
public Account(String name) {
this.name = name;
this.accountId = "";
}
}
Controller.java
我的@SpringBootApplication
@RestController
@EnableAutoConfiguration
public class AccountServiceApplication {
public static void main(String[] args) {
SpringApplication.run(AccountServiceApplication.class, args);
}
@RequestMapping(value="/", method=RequestMethod.GET)
Account root() {
Account a = new Account("john doe");
return a;
}
}
如下:
build.gradle
当我卷曲我的Web应用程序时,我得到以下响应:
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
id 'war'
id 'com.google.cloud.tools.jib' version '0.9.6'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-json'
}
我已检查自己的依存关系中有{"timestamp":"2019-03-09T10:21:29.648+0000","status":500,"error":"Internal Server Error","message":"No converter found for return value of type: class account.Account","path":"/"}
。它不应该自动转换为JSON吗?