我想从命令行运行“mvn tomcat:run”,但是如何编辑server.xml以在连接器中设置maxHttpHeaderSize =“65536”?或者我可以在pom.xml中配置连接器吗?mvn tomcat:运行 - 如何编辑server.xml?
干杯
聂
我想从命令行运行“mvn tomcat:run”,但是如何编辑server.xml以在连接器中设置maxHttpHeaderSize =“65536”?或者我可以在pom.xml中配置连接器吗?mvn tomcat:运行 - 如何编辑server.xml?
干杯
聂
不幸的是,做一些研究之后,我不认为有编辑server.xml的连接方式。 mvn tomcat:run
使用嵌入式Tomcat。
除非有人发现某些东西,否则您最好的办法是转移到maven cargo plugin并使用您的自定义server.xml
将自己的Tomcat安装到ZIP上。
<cargo containerId="tomcat7x" [...]>
<zipUrlInstaller
installUrl="file://tomcat-custom.zip",
installDir="target/installs"/>
[...]
</cargo>
或诸如此类的东西...
看到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>
并使用默认货物server.xml作为模板来获取pr operty更换:
<Server port="@[email protected]" shutdown="SHUTDOWN" debug="@[email protected]">
<Service name="Catalina" debug="@[email protected]">
<Connector port="@[email protected]"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
scheme="@[email protected]" secure="@[email protected]"
debug="@[email protected]"
emptySessionPath="@[email protected]"
URIEncoding="@[email protected]" />
<!-- Define an AJP 1.3 Connector on port @[email protected] -->
<Connector port="@[email protected]" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="@[email protected]"
debug="@[email protected]">
<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="@[email protected]"
However, doing this result in a NullPointerException in
ExpandWar.java at line 145. -->
<Host name="@[email protected]" appBase="webapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<!-- Contexts to explicitely point to where the wars are located -->
@[email protected]
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="@[email protected]_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
</Host>
</Engine>
</Service>
</Server>
我一直在使用serverXml参数为tomcat:run
目标(http://tomcat.apache.org/maven-plugin-2/tomcat6-maven-plugin/run-mojo试验。 HTML#serverXml)。
以下server.xml
似乎运行没有错误,但没有Context
元素它不加载webapp。我想,如果我从SRC复制我Context
元/主/ web应用/ 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
的目标可能要tomcat6:run
如果您正在使用一个版本,同时支持Tomcat的6和7
的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>
看来你是对的,也没有办法做到这一点比我自己的滚动破解,比如通过货运插件等的那一刻。 – niklassaers 2010-09-16 07:49:40