简体   繁体   English

增加tomcat7 maven插件的内存?

[英]Increase memory of tomcat7 maven plugin?

I want to start an embedded tomcat7 instance directly from maven using the tomcat7-maven-plugin. 我想使用tomcat7-maven-plugin直接从maven启动一个嵌入式tomcat7实例。 This is working fine, but the Tomcat started doesn't seem to have enough memory. 这工作正常,但Tomcat启动似乎没有足够的内存。 I suspect that I would need to set 我怀疑我需要设置

-XX:MaxPermSize=256m

but I can't figure out how to do it. 但我无法弄清楚该怎么做。

The documentation says one should use the "systemProperties" element in the "configuration" section of the plugin. 文档说应该使用插件的“配置”部分中的“systemProperties”元素。 However, the options are specified as XML elements and would need to look like that: 但是,选项被指定为XML元素,并且需要看起来像这样:

<configuration>
  <systemProperties>
    <XX:MaxPermSize>256m</XX:MaxPermSize>
  </systemProperties>
</configuration>

But that's of course not possible as it breaks the XML (XX is interpreted as a namespace). 但这当然不可能,因为它打破了XML(XX被解释为命名空间)。

Of course I could get around this problem by setting environment variable 当然,我可以通过设置环境变量来解决这个问题

MAVEN_OPTS=-XX:MaxPermSize=256m

but I would prefer to only increase it for the embedded Tomcat. 但我宁愿只为嵌入式Tomcat增加它。 Any ideas how to do that? 任何想法如何做到这一点?

As most said in the comments above the properties in pom.xml has no effct. 正如大多数人在上面的评论中所说,pom.xml中的属性没有效果。 What worked for me was setting my MAVEN_OPTS 对我有用的是设置我的MAVEN_OPTS

MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

Or on Windows in a cmd terminal: 或者在cmd终端的Windows上:

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

For mac/linux users, just add an export statement to your ~/.profile (or similar file name). 对于mac / linux用户,只需在〜/ .profile(或类似文件名)中添加一个export语句。 For example: 例如:

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

And restart your shell. 然后重启你的shell。

You can set the properties in this way 您可以通过这种方式设置属性

<configuration>
  <systemProperties>
    <JAVA_OPTS>-Xms256m -Xmx512m -XX:MaxPermSize=256m</JAVA_OPTS>
  </systemProperties>
</configuration>

This one worked for me: 这个对我有用:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>...</version>
    <configuration>
        <container>...</container>
        <configuration>
            <type>standalone</type>
            <home>...</home>
            <properties>
                <cargo.jvmargs>-Xmx4096m</cargo.jvmargs>
            </properties>
        </configuration>
        <deployables>...</deployables>
    </configuration>
</plugin>

It starts up my tomcat8 in a new JVM with argument "-Xmx4096m". 它在一个带有参数“-Xmx4096m”的新JVM中启动我的tomcat8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM