Using Maven settings.xml properties inside Spring context

前端 未结 3 1793
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 18:17

I\'ve got a Maven settings.xml file in my ~/.m2 directory; it looks like this:


    
        

        
3条回答
  •  情话喂你
    2020-12-20 18:57

    I recommend you to use a property file in the middle. I mean: Spring application would load properties values form the property file using context:property-placeholder and Maven would be the one who replace ${...} variables using values from settings.xml using filtering.

    Your property file:

    db.driver=${db.driver}
    db.url=${db.url}
    username=${username}
    password=${password}
    

    Your servlet-context.xml file

    
    
    
        ${db.driver}
        ${db.url}
        ${username}
        ${password}
    
    

    In your pom.xml

    
        ...
        
            src/main/resources
            true
        
        ...
    
    

提交回复
热议问题