maven环境虽然能够有效地管理jar包,使得本来100M的项目变成了45M,果然是好的管理工具。同时,如果配置不好也会带来一些麻烦,比如Exception in thread "http-bio-8080-exec-10" java.lang.OutOfMemoryError: Perm。这个问题大多数时候都是内存不足,而在maven环境下tomcat7插件是采用语句配置的方式,相信那些平时用惯了本地tomcat7的程序员会不习惯,会因为找不到配置文件而苦恼。
maven在配置tomcat7时候采用了一条命令语句:-X compile -Dmaven.test.skip=true -Pdev tomcat7:run 而参数的配置不合适就或者不配置参数而采用默认的参数配置都会导致内存溢出。
解决办法很简单,在%M2_HOME%/bin/mvn.bat中配置参数set MAVEN_OPTS= -Xms1024m -Xmx2048m 即可。
maven配置tomcat7的方法:
1、在pom.xml文件中设置tomat7插件,如下:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
2、设置run命令::-X compile -Dmaven.test.skip=true -Pdev tomcat7:run