配置文件依赖web.xml

Pab*_*mer 0 ssl tomcat config maven

我在我的生产服务器上使用强制ssl配置为tomcat.我想在开发中禁用此功能,并想知道我的选项是什么.配置发生在我的web.xml文件中.我目前使用maven构建我的项目,所以我已经有一些配置文件,其中我更喜欢设置设置.

The*_*nor 5

您的web.xml中的某个位置可能具有以下设置:

<transport-guarantee>CONFIDENTIAL</transport-guarantee>
Run Code Online (Sandbox Code Playgroud)

如果是这样,您可以使用属性占位符作为传输保证属性,并在构建期间对资源进行过滤.用以下内容替换web.xml中的那一行:

<transport-guarantee>${transport.guarantee}</transport-guarantee>
Run Code Online (Sandbox Code Playgroud)

您可以将默认值"CONFIDENTIAL"分配给pom文件或外部属性文件中的属性$ {transport.guarantee},并通过提供命令行参数在开发环境中覆盖它:

mvn clean package -Dtransport.guarantee="NONE"
Run Code Online (Sandbox Code Playgroud)

如果您使用的是maven war插件,可以通过以下方式在pom文件中启用资源过滤:

      <configuration>
                <webResources>
                    <resource>
                        <filtering>true</filtering>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/web.xml</include>
                        </includes>
                    </resource>
                </webResources>
                <warSourceDirectory>src/main/webapp</warSourceDirectory>
                <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
            </configuration>
Run Code Online (Sandbox Code Playgroud)

最后,如果您必须使用现有的配置文件,则根据哪个配置文件处于活动状态来设置transport.guarantee的值.一种方法:

<profiles>
 <profile>
  <id>development</id>
  <properties>
    <transport.guarantee>NONE</transport.guarantee>
  </properties>
</profile>
<profile>
  <id>production</id>
  <properties>
    <transport.guarantee>CONFIDENTIAL</transport.guarantee>
  </properties>
</profile>
Run Code Online (Sandbox Code Playgroud)

您希望将生产配置文件设置为活动状态作为默认设置.使用〜/ .m2/settings.xml文件覆盖并使您的开发配置文件处于活动状态.