How do I load a resource and use its contents as a string in Spring

前端 未结 5 1020
春和景丽
春和景丽 2020-12-04 17:48

How can I load a Spring resource contents and use it to set a bean property or pass it as an argument constructor?

The resource contains free text.

5条回答
  •  执笔经年
    2020-12-04 18:12

    This is one way of doing it without using any external library.. default provided by spring.. environment.properties file contains key value pairs...reference each value with ${key}

    here in my example, I am keeping database props

    
        
            
                classpath:environment.properties
    
            
        
    
    
        
        
        
        
    
    

提交回复
热议问题