The “import java.util.function cannot be resolved” error

后端 未结 8 1609
感动是毒
感动是毒 2021-01-11 12:49

I\'m trying to run this practice script from the standard Oracle Java tutorials.

This seems to be a common error and I\'ve used SO resources to make attempts to fix

8条回答
  •  清歌不尽
    2021-01-11 13:25

    I had something similar with Apache Camel: the following function was not working anymore

    String headerKey = exchange.getIn().getHeader("headerKey",String.class);
    

    because of the error-message:

    The type java.util.function.Supplier cannot be resolved. It is indirectly referenced from required .class files
    

    To solve the issue I change the casting and it worked afterwards:

    String headerKey = (String) exchange.getIn().getHeader("headerKey");
    

    maybe it helps you or somebody else.

    One other point to mention here would be the Apache Camel version itself as stated on the official page linked here.

提交回复
热议问题