Default profile in Spring 3.1

前端 未结 7 1081
执笔经年
执笔经年 2020-11-28 19:56

In my application I have beans annotated with @Profile(\"prod\") and @Profile(\"demo\"). The first one, as you can guess :), is used on beans that

7条回答
  •  借酒劲吻你
    2020-11-28 20:46

    You can setup your web.xml as filtered resource and have this value filled by maven from maven profile settings - that what we do.

    in pom filter all resources (you can do taht if you have no ${} marking in them)

    
        
            src/main/webapp
            true
        
    
    

    in web.xml put

    
         spring.profiles.active
         ${spring.prfile}
    
    

    in pom create maven profiles

    
        
            DEFAULT
            
                true
            
            
                prod
            
        
        
            DEMO
            
                demo
            
        
    
    

    Now you can use

    mvn jetty:run -P DEMO
    

    or simply -P DEMO with any maven command

提交回复
热议问题