首页 > 解决方案 > 如何将带注释的类@Configuration 作为 REST 响应发送?在springboot中

问题描述

我想发送这个类作为 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)

标签: spring-bootserializationjackson

解决方案


推荐阅读