jetty maven中的配置:
1 <pluginManagement> 2 <plugins> 3 <plugin> 4 <groupId>org.eclipse.jetty</groupId> 5 <artifactId>jetty-maven-plugin</artifactId> 6 <version>9.3.0.M2</version> 7 <configuration> 8 9 <scanIntervalSeconds>10</scanIntervalSeconds> 10 <stopKey>ch06</stopKey> 11 <stopPort>9090</stopPort> 12 <webAppSourceDirectory>${project.basedir}/src/main/webapp</webAppSourceDirectory> 13 <webapp> 14 <contextPath>/</contextPath> 15 <descriptor>${project.basedir}/src/main/webapp/WEB-INF/web.xml</descriptor> 16 </webapp> 17 <classesDirectory>${project.basedir}/target/classes</classesDirectory> 18 <scanTargets> 19 <scanTarget>src/main/resources</scanTarget> 20 </scanTargets> 21 <scanTargetPatterns> 22 <scanTargetPattern> 23 <directory>src/main/resources</directory> 24 <includes> 25 <include>**/*.xml</include> 26 <include>*.xml</include> 27 </includes> 28 </scanTargetPattern> 29 </scanTargetPatterns> 30 <war>${project.basedir}/target/ch06.war</war> 31 </configuration> 32 <executions> 33 <execution> 34 <id>start-jetty</id> 35 <phase>test-compile</phase> 36 <goals> 37 <goal>deploy-war</goal> 38 </goals> 39 </execution> 40 <execution> 41 <id>stop-jetty</id> 42 <phase>test</phase> 43 <goals> 44 <goal>stop</goal> 45 </goals> 46 </execution> 47 </executions> 48 </plugin> 49 </plugins> 50 51 </pluginManagement>
这是初步的配置,随着项目的进行,我们会发现,当我们过多的修改了我们的程序,他会报内存溢出的错误。
因此,我们需要配置他的内存以及设置垃圾的自动回收机制。
-server -Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDetails -Xloggc:%M2_HOME%/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%M2_HOME%/java_pid.hprof
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 <groupId>com.ujsnews</groupId> 5 <artifactId>ch06</artifactId> 6 <packaging>war</packaging> 7 <version>0.0.1-SNAPSHOT</version> 8 <name>ch06 Maven Webapp</name> 9 <url>http://maven.apache.org</url> 10 <properties> 11 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 12 <project.deploy>deploy</project.deploy> 13 <project.tomcat.version>8.0.0-RC5</project.tomcat.version> 14 </properties> 15 <dependencies> 16 <dependency> 17 <groupId>junit</groupId> 18 <artifactId>junit</artifactId> 19 <version>4.12</version> 20 <scope>test</scope> 21 </dependency> 22 <!-- 23 web引用的框架文件 24 --> 25 <dependency> 26 <groupId>org.hibernate</groupId> 27 <artifactId>hibernate-core</artifactId> 28 <version>3.6.10.Final</version> 29 </dependency> 30 31 <dependency> 32 <groupId>org.springframework</groupId> 33 <artifactId>spring-core</artifactId> 34 <version>3.2.13.RELEASE</version> 35 </dependency> 36 37 <dependency> 38 <groupId>org.springframework</groupId> 39 <artifactId>spring-orm</artifactId> 40 <version>3.2.13.RELEASE</version> 41 </dependency> 42 43 <dependency> 44 <groupId>org.springframework</groupId> 45 <artifactId>spring-beans</artifactId> 46 <version>3.2.13.RELEASE</version> 47 </dependency> 48 49 <dependency> 50 <groupId>org.springframework</groupId> 51 <artifactId>spring-context</artifactId> 52 <version>3.2.13.RELEASE</version> 53 </dependency> 54 55 <dependency> 56 <groupId>org.springframework</groupId> 57 <artifactId>spring-web</artifactId> 58 <version>3.2.13.RELEASE</version> 59 </dependency> 60 61 <dependency> 62 <groupId>org.aspectj</groupId> 63 <artifactId>aspectjweaver</artifactId> 64 <version>1.8.5</version> 65 </dependency> 66 67 <dependency> 68 <groupId>mysql</groupId> 69 <artifactId>mysql-connector-java</artifactId> 70 <version>5.1.34</version> 71 </dependency> 72 73 <!-- 74 <dependency> 75 <groupId>org.apache.struts</groupId> 76 <artifactId>struts2-core</artifactId> 77 <version>2.3.20</version> 78 </dependency> 79 --> 80 <dependency> 81 <groupId>org.apache.struts</groupId> 82 <artifactId>struts2-spring-plugin</artifactId> 83 <version>2.3.20</version> 84 </dependency> 85 86 <dependency> 87 <groupId>commons-logging</groupId> 88 <artifactId>commons-logging</artifactId> 89 <version>1.2</version> 90 </dependency> 91 <!-- 92 <dependency> 93 <groupId>com.opensymphony</groupId> 94 <artifactId>xwork-core</artifactId> 95 <version>2.1.6</version> 96 </dependency> 97 --> 98 <!-- 99 j2ee开发环境 100 --> 101 <dependency> 102 <groupId>javax.servlet</groupId> 103 <artifactId>javax.servlet-api</artifactId> 104 <version>3.1.0</version> 105 <scope>provided</scope> 106 </dependency> 107 108 <dependency> 109 <groupId>javax.servlet</groupId> 110 <artifactId>jsp-api</artifactId> 111 <version>2.0</version> 112 <scope>provided</scope> 113 </dependency> 114 <dependency> 115 <groupId>org.eclipse.jetty</groupId> 116 <artifactId>jetty-server</artifactId> 117 <version>9.3.0.M2</version> 118 <scope>provided</scope> 119 </dependency> 120 121 <dependency> 122 <groupId>org.apache.lucene</groupId> 123 <artifactId>lucene-core</artifactId> 124 <version>4.10.4</version> 125 </dependency> 126 <dependency> 127 <groupId>org.apache.lucene</groupId> 128 <artifactId>lucene-highlighter</artifactId> 129 <version>4.10.4</version> 130 </dependency> 131 <dependency> 132 <groupId>org.apache.lucene</groupId> 133 <artifactId>lucene-memory</artifactId> 134 <version>4.10.4</version> 135 </dependency> 136 137 <dependency> 138 <groupId>org.apache.poi</groupId> 139 <artifactId>poi</artifactId> 140 <version>3.11</version> 141 </dependency> 142 <dependency> 143 <groupId>org.apache.poi</groupId> 144 <artifactId>poi-scratchpad</artifactId> 145 <version>3.11</version> 146 </dependency> 147 148 <dependency> 149 <groupId>org.apache.poi</groupId> 150 <artifactId>poi-ooxml</artifactId> 151 <version>3.11</version> 152 </dependency> 153 <dependency> 154 <groupId>org.apache.poi</groupId> 155 <artifactId>poi-ooxml-schemas</artifactId> 156 <version>3.11</version> 157 </dependency> 158 <dependency> 159 <groupId>org.apache.poi</groupId> 160 <artifactId>ooxml-schemas</artifactId> 161 <version>1.1</version> 162 </dependency> 163 <dependency> 164 <groupId>org.apache.poi</groupId> 165 <artifactId>openxml4j</artifactId> 166 <version>1.0-beta</version> 167 </dependency> 168 <dependency> 169 <groupId>org.apache.poi</groupId> 170 <artifactId>poi-contrib</artifactId> 171 <version>3.6</version> 172 </dependency> 173 <dependency> 174 <groupId>fr.opensagres.xdocreport</groupId> 175 <artifactId>xdocreport</artifactId> 176 <version>1.0.5</version> 177 </dependency> 178 179 <dependency> 180 <groupId>org.docx4j</groupId> 181 <artifactId>docx4j</artifactId> 182 <version>3.2.1</version> 183 </dependency> 184 <dependency> 185 <groupId>org.apache.tomcat</groupId> 186 <artifactId>tomcat-servlet-api</artifactId> 187 <version>${project.tomcat.version}</version> 188 <scope>provided</scope> 189 </dependency> 190 </dependencies> 191 <build> 192 <finalName>ch06</finalName> 193 194 <pluginManagement> 195 <plugins> 196 <plugin> 197 <groupId>org.eclipse.jetty</groupId> 198 <artifactId>jetty-maven-plugin</artifactId> 199 <version>9.3.0.M2</version> 200 <configuration> 201 202 <scanIntervalSeconds>10</scanIntervalSeconds> 203 <stopKey>ch06</stopKey> 204 <stopPort>9090</stopPort> 205 <webAppSourceDirectory>${project.basedir}/src/main/webapp</webAppSourceDirectory> 206 <webapp> 207 <contextPath>/</contextPath> 208 <descriptor>${project.basedir}/src/main/webapp/WEB-INF/web.xml</descriptor> 209 </webapp> 210 <classesDirectory>${project.basedir}/target/classes</classesDirectory> 211 <scanTargets> 212 <scanTarget>src/main/resources</scanTarget> 213 </scanTargets> 214 <scanTargetPatterns> 215 <scanTargetPattern> 216 <directory>src/main/resources</directory> 217 <includes> 218 <include>**/*.xml</include> 219 <include>*.xml</include> 220 </includes> 221 </scanTargetPattern> 222 </scanTargetPatterns> 223 <war>${project.basedir}/target/ch06.war</war> 224 </configuration> 225 <executions> 226 <execution> 227 <id>start-jetty</id> 228 <phase>test-compile</phase> 229 <goals> 230 <goal>deploy-war</goal> 231 </goals> 232 </execution> 233 <execution> 234 <id>stop-jetty</id> 235 <phase>test</phase> 236 <goals> 237 <goal>stop</goal> 238 </goals> 239 </execution> 240 </executions> 241 </plugin> 242 </plugins> 243 244 </pluginManagement> 245 <!-- 246 <plugin> 247 <artifactId>maven-resources-plugin</artifactId> 248 <version>2.6</version> 249 <executions> 250 <execution> 251 <id>copy-resources</id> 252 253 <phase>package</phase> 254 <goals> 255 <goal>copy-resources</goal> 256 </goals> 257 <configuration> 258 <outputDirectory>G:/tomcat8/webapps</outputDirectory> 259 <resources> 260 <resource> 261 <directory>${basedir}/target/ch06.war</directory> 262 <filtering>true</filtering> 263 </resource> 264 </resources> 265 </configuration> 266 </execution> 267 </executions> 268 </plugin> 269 270 </plugins> 271 </pluginManagement> 272 --> 273 <!-- 274 <plugins> 275 <plugin> 276 <groupId>org.apache.maven.plugins</groupId> 277 <artifactId>maven-compiler-plugin</artifactId> 278 <version>3.1</version> 279 <configuration> 280 <source>1.7</source> 281 <target>1.7</target> 282 <compilerArguments> 283 <extdirs>src/main/webapp/WEB-INF/lib</extdirs> 284 </compilerArguments> 285 <archive> 286 <addMavenDescriptor>false</addMavenDescriptor> 287 </archive> 288 </configuration> 289 </plugin> 290 <plugin> 291 <groupId>org.apache.tomcat.maven</groupId> 292 <artifactId>tomcat7-maven-plugin</artifactId> 293 <version>2.2</version> 294 <configuration> 295 <url>http://localhost:8080/manager/text</url> 296 <username>tomcat</username> 297 <password>tomcat</password> 298 <path>/${project.artifactId}</path> 299 </configuration> 300 </plugin> 301 </plugins> 302 303 <plugins> 304 <plugin> 305 <groupId>org.apache.maven.plugins</groupId> 306 <artifactId>maven-dependency-plugin</artifactId> 307 <version>2.1</version> 308 <executions> 309 <execution> 310 <id>copy-dependencies</id> 311 <phase>package</phase> 312 <goals> 313 <goal>copy-dependencies</goal> 314 </goals> 315 <configuration> 316 <outputDirectory>${basedir}/src/main/webapp/WEB-INF/lib</outputDirectory> 317 </configuration> 318 </execution> 319 </executions> 320 </plugin> 321 </plugins> 322 --> 323 324 </build> 325 </project>
原文:http://www.cnblogs.com/pingbo/p/4386458.html