Spring: Inject URL for classpath resource

后端 未结 4 660
野性不改
野性不改 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:19

    create your own implementation of a spring resource by extending the org.springframework.core.io.ClassPathResource like MyClasspathResource extends ClassPathResource and inject this type into your bean. Like this you do not have any dependency to spring and can later reimplement your resource with something else.

    
     
      
       
      
     
    
    

提交回复
热议问题