简体   繁体   English

覆盖Maven中的系统属性

[英]overriding system properties in maven

I have a web application with a couple of profiles - for production and for local testing; 我有一个带有几个配置文件的Web应用程序-用于生产和本地测试。 build is executed with maven; 用maven执行构建; logback is used for logging logback用于记录日志

so some of logs write to files - the problem is: in production we use tomcat and CATALINA_HOME is set on server, but locally we often use jetty, so tomcat may even not be configured 所以一些日志写入文件-问题是:在生产中,我们使用tomcat并且在服务器上设置了CATALINA_HOME,但是在本地我们经常使用码头,因此甚至可能未配置tomcat

so in prod i want to write log in file this way: ${catalina.home}/logs/profiler.%d{yyyy-MM-dd}.log 所以在生产中,我想以这种方式写入登录文件:$ {catalina.home} /logs/profiler.%d {yyyy-MM-dd} .log

how do I set maven override this ${catalina.home} property 我如何设置Maven覆盖此$ {catalina.home}属性

  1. how do i set it from maven (do i need system properties or just maven properties) 我如何从Maven设置它(我需要系统属性还是仅Maven属性)
  2. may i make it conditional? 我可以有条件吗? (if it is not set on the local system then use the property defined in #1) (如果未在本地系统上设置,则使用#1中定义的属性)

thanks a lot! 非常感谢! tatiana. 塔蒂亚娜。

You can define a maven property , say log.dir and set it to appropriate values in each profile . 您可以定义一个maven property ,例如log.dir并在每个profile中将其设置为适当的值。

Say, 说,

    <profile>
        <id>dev</id>
        <properties>
            <log.dir>${catalina.home}/...</log.dirv>
        </properties>
    </profile>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM