作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何使用 Eclipse 删除 Java 中“Map”后面的类型安全标记?
Map<String, String> errorStatus = exchange.getIn().getHeader("totalCount", Map.class);
它打印以下消息。
The Expression of type map needs unchecked conversion to confirm to Map<String,String>
更新:
getIn() 和 getHeader 是内置的 Camel 方法。在一条 route ,我有 setHeader("headerkey",mapOfErrors) ,当我进一步需要这个错误键时,我只是使用这些函数从 Camel Message 中获取它。以下是 getHeader() 的可用参数:
最佳答案
如您所知,没有 Map<String,String>.class
,据我所知,对于您的情况,您有两种选择:首先创建一个包装类来扩展 HashMap,然后您可以使用 Wapper.class,我不推荐
WrapperClass errorStatus = exchange.getIn().getHeader("totalCount", Wrapper.class);
第二种方法只是忽略此警告并使用 @SuppressWarnings("unchecked")
关于Java 与 Eclipse : Type Safety: The Expression of type map needs unchecked conversion to confirm to Map<String, 字符串>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61931925/
我是一名优秀的程序员,十分优秀!