mvn tomcat:运行 - 如何编辑server.xml?

我想从命令行运行“mvn tomcat:run”,但是如何编辑server.xml以在连接器中设置maxHttpHeaderSize =“65536”?或者我可以在pom.xml中配置连接器吗? 干杯 聂     
已邀请:
不幸的是,经过一些研究,我认为没有办法编辑server.xml的连接器。
mvn tomcat:run
使用嵌入式Tomcat。 除非有人找到某些东西,否则最好的选择是转移到maven货运插件并使用您的自定义
server.xml
压缩您自己的Tomcat安装。
<cargo containerId="tomcat7x" [...]>
  <zipUrlInstaller
      installUrl="file://tomcat-custom.zip",
      installDir="target/installs"/>
  [...]
</cargo>
或类似的东西......     
org.codehaus.mojo:tomcat-maven-plugin将允许您在配置部分中设置server.xml文件的路径:
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>
  <configuration>
    <serverXml>path_to_server_xml_file</serverXml>
  </configuration>
</plugin>
    
我一直在尝试使用serverXml参数来实现
tomcat:run
目标(http://tomcat.apache.org/maven-plugin-2/tomcat6-maven-plugin/run-mojo.html#serverXml)。 以下
server.xml
似乎运行没有错误,但没有
Context
元素它不加载webapp。我想如果我将我的
Context
元素从src / main / webapp / META-INF / context.xml复制到
Host
元素内部,它可能会正常工作:
<?xml version='1.0' encoding='utf-8'?>
<Server port="-1" shutdown="SHUTDOWN">
    <Service name="Catalina">
        <Connector port="8080" protocol="HTTP/1.1" />
        <Engine name="Catalina" defaultHost="localhost">
            <Host name="localhost" appBase="webapps">
            </Host>
        </Engine>
    </Service>
</Server>
要使用此服务器运行,我将serverXml作为Maven命令行上的属性传递:
mvn -Dmaven.tomcat.serverXml=src/main/resources/server.xml tomcat:run
如果您使用的是支持Tomcat 6和7的插件版本,那么目标可能必须是
tomcat6:run
。     
请参阅http://docs.codehaus.org/display/CARGO/Custom+File+Configurations 我认为你可以这样做,并将自定义server.xml放在你的项目中:
<configuration>
    <type>standalone</type>
    <configfiles> 
        <configfile> 
            <file>${basedir}/src/main/resources/server.xml</file> 
            <todir>conf</todir> 
        </configfile> 
    </configfiles> 
</configuration>
并使用default cargo server.xml作为模板来获取属性:
<Server port="@cargo.rmi.port@" shutdown="SHUTDOWN" debug="@catalina.logging.level@">

  <Service name="Catalina" debug="@catalina.logging.level@">

    <Connector port="@cargo.servlet.port@"
        maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
        enableLookups="false" redirectPort="8443" acceptCount="100"
        connectionTimeout="20000" disableUploadTimeout="true"
        scheme="@cargo.protocol@" secure="@catalina.secure@"
        debug="@catalina.logging.level@"
        emptySessionPath="@catalina.connector.emptySessionPath@"
        URIEncoding="@catalina.servlet.uriencoding@" />

    <!-- Define an AJP 1.3 Connector on port @cargo.tomcat.ajp.port@ -->
    <Connector port="@cargo.tomcat.ajp.port@" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="@cargo.hostname@" 
        debug="@catalina.logging.level@">

      <Realm className="org.apache.catalina.realm.MemoryRealm" />

      <!-- Note: There seems to be a bug in Tomcat 5.x if the debug attribute 
           is present. Ideally we would have written:
               debug="@catalina.logging.level@"
           However, doing this result in a NullPointerException in 
           ExpandWar.java at line 145. -->
      <Host name="@cargo.hostname@" appBase="webapps" unpackWARs="true"
          autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

        <!-- Contexts to explicitely point to where the wars are located -->
        @tomcat.webapps@

        <Valve className="org.apache.catalina.valves.AccessLogValve"
            directory="logs" prefix="@cargo.hostname@_access_log." suffix=".txt"
            pattern="common" resolveHosts="false"/>

      </Host>
    </Engine>
  </Service>
</Server>
    

要回复问题请先登录注册