Accessing gradle resources from Java

后端 未结 3 2170
一整个雨季
一整个雨季 2021-02-19 08:17

I have a gradle-based java project with this structure

.
├── myproject
│      ├── src
│      |    └── main
│      |         ├── java
│      |         └── resourc         


        
3条回答
  •  遥遥无期
    2021-02-19 08:37

    Maybe you should use it this way:

    
    Thread.currentThread().getContextClassLoader().getResource("myresource.xml")
    
    

    If i use ClassLoader.getSystemClassLoader().getResource("myresource.xml")

    When I use it as a jar package embedded in other applications, I still have no access to resources.

提交回复
热议问题