spring-boot - 如何将带注释的类@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)
解决方案
推荐阅读
- flutter - 如何不在网格视图中显示当前用户?
- sql - 如何在 SQL Server 2012 中将逗号分隔的变量值转换为行?
- python - 检查数据框中的列是否包含列表中的任何单词+添加计数(Python)
- azure - 无法通过邮递员中的 Microsoft Graph API 获取消息
- python-3.x - 用于重复记录的 Python Pandas 外连接
- excel - 如何在多个 Excel 中搜索值并汇总到一个 Excel 工作簿
- c# - 如何在 asp.net 中读取 gridview 列和行数据?
- flutter - 如何在 Flutter 中添加加载屏幕
- amazon-web-services - AWS Lambda (URL) 重写流程
- javascript - html2canvas 在渲染完成后停止