Resources.getResourceAsStream(resource) can not find the method to solve the problem

Question details

When reading the configuration file, when I typed InputStream in = Resources.getResourceAsStream("SqlMapConfig.xml");it, I found that the getResourceAsStream() method was marked in red, and IDEA said there was no such method.

This article provides a real solution, let you find this method

problem solved

Foreword
After a visit to my csdn, many blogs said it was changed to nputStream inputStream = Resources.class.getResourceAsStream(resource);
I changed it and found that it works, but it feels weird.
Then when Insert picture description here
I ran it, I found this error was reported, so I checked the corresponding solution again. When solving this problem, I stumbled upon a solution to the getResourcesAsStream() method.

Solution:
First of all, make sure that the JDK version of file-Project structure-Project is set to the one that you use. I here is 9
Insert picture description here
and the module here is also changed to 9, keeping the same
Insert picture description here
** After doing this, you can find the getResourceAsStream() method. . **This solution does not use Resources.class,
but I can’t explain the reason, so let’s use it first (it may be caused by the previous module jdk version 5. It’s too low and there is no such method)

################### If you still
can try this set
Insert picture description here
it down on it firmly

Guess you like

Origin blog.csdn.net/qq_34687559/article/details/110235887