如何发送带有@Configuration注释的类作为REST响应?在springboot中

时间:2018-07-23 18:20:33

标签: spring-boot serialization jackson

我想发送此类作为REST服务的响应

@Configuration
@ConfigurationProperties(prefix = "test")
public class Test { 
private String str;
}

控制器具有方法:

@Autowired
private Test test;

@GetMapping("/url")
public Test config() {
    return test;
}

我得到的异常是:

Type definition error: [simple type, class org.springframework.beans.support.ResourceEditorRegistrar]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.springframework.beans.support.ResourceEditorRegistrar and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

0 个答案:

没有答案