Spring: Inject URL for classpath resource

后端 未结 4 690
野性不改
野性不改 2021-01-11 09:53

I want to inject the URL of a classpath resource in a way that does not create a dependency on Spring in the Bean. Meaning, the bean should not use Spring\'s interfaces/clas

4条回答
  •  温柔的废话
    2021-01-11 10:17

    Spring is able to convert classpath:... values into java.net.URL implicitly:

    public class Foo {
        private URL url;
        ...
    }
    

    .

    
        
    
    

提交回复
热议问题