Conditionally exclude some resources in maven from war

前端 未结 2 1737
Happy的楠姐
Happy的楠姐 2021-01-21 02:40

I developed an application, and its final war was OK in a development mode but it contains some configuration files which I need to externalize for production. I was able to man

2条回答
  •  时光说笑
    2021-01-21 03:13

    Please DON'T use profiles for this. The problem with profiles is that the resulting artifact contains no information about the profiles used to build it.

    Basic rule: A profile must not change the result of the build.

    Or the other way around: If you build the same source code revision, the result must be identical, regardless of profiles or arguments.

    (see How to really use Maven profiles (without endangering your karma) for more information)

    So, a better way to do it would be to create two war modules, say my-project and my-project-dev.war.

    If my-project-dev.war has a war-dependency on my-project.war, it will use your production war as overlay, resulting in a combined war files using your production and your development time resources.

    Added bonus feature: in your development war, you can override entries of your production war (say, logging-config).

提交回复
热议问题