Home>

Why when I try to call ServiceImpl.class.getClassLoader (). getResource ("coopAccess_db") null is returned to me and it is worth putting it in a folder and specifying the appropriate path getResource ("db /coopAccess_db") a normal url is returned

What url is returned?

Roman C2021-02-23 05:03:54

In the first case, null in the second file: /C: /Users /user /Documents /IntelijIdeaRes /IdeaProjects /CoopAccess_Server /target /classes /db /coopAccess_db

Clool Mear2021-02-23 05:03:54

Is there such a file?

Roman C2021-02-23 05:03:54

of course, I threw the screen, but it finds the file only if it is also thrown into an additional directory

Clool Mear2021-02-23 05:03:54

What is the name of the file?

Roman C2021-02-23 05:03:54
  • Answer # 1

    Contact like this:

    ServiceImpl.class.getResource ("/coopAccess_db");
    

    tried null too

    Clool Mear2021-02-23 05:03:54

    Make sure that the file you are looking for is in the root of the jar file after building the project. If it is not there, it will not look like that.

    ezhov_da2021-02-23 05:03:54
Trends