0

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

4

1 回答 1

5

在 web.xml 中的某处,您可能有以下设置:

<transport-guarantee>CONFIDENTIAL</transport-guarantee>

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

<transport-guarantee>${transport.guarantee}</transport-guarantee>

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

mvn clean package -Dtransport.guarantee="NONE"

如果您使用的是 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>

最后,如果您必须使用现有配置文件,则根据激活的配置文件设置 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>

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

于 2013-08-26T12:52:27.660 回答