jetty maven的配置

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>

这是初步的配置,随着项目的进行,我们会发现,当我们过多的修改了我们的程序,他会报内存溢出的错误。

因此,我们需要配置他的内存以及设置垃圾的自动回收机制。

解决办法:

设置run as --->run configuragtions--->jre标签下的属性VM arguments:

-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

其中参数说明如下:

-XX:+CMSPermGenSweepingEnabled : 允许permgenspace的垃圾回收

-XX:+CMSClassUnloadingEnabled : allows the garbage collector to remove even classes from the memory

-XX:PermSize=256M -XX:MaxPermSize=256M : raises the amount of memory allocated to the permgenspace

解决失败用例:

1.在系统环境变量中添加 MAVEN_OPTS="-Xms40m -Xmx512m -XX:PermSize=512m" 不行,

2.在eclipse.ini文件中添加 -Xms40m -Xmx512m -XX:PermSize=512m 也不行。

3.run as --->run configuragtions--->jre标签下的属性VM arguments:

-Xms512m -Xmx1024m

附:pom代码(项目为:struts2+Spring3+hibernate+lucene+poi)

  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>

时间: 2024-08-29 23:12:56

jetty maven的配置的相关文章

Jetty Maven Plugin配置

官方文档:http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#maven-config-https 1,在pom.xml中引入jetty插件 <build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</

Eclipse+Maven(webapp)+Jetty+JReBel的配置方法

maven配置 省略 jrebel配置 jrebel毋须繁琐的配置,把jrebel-5.6.3-crack.zip解压放在磁盘文件夹就可以.(笔者路径为:D:\coding-life\IDE\jrebel\jrebel-5.6.3-crack)该路径兴许须要引用到 Eclipse配置 打开菜单Run > Debug configurations... 找到Maven Build.新建一个Maven命令配置.如图: 新建的相关面板配置例如以下(名称可自己定义,我这里取名为insurance-jet

Spring+Mybatis+Maven 整合配置

1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans default-autowire="byName" 3 xmlns="http://www.springframework.org/schema/beans" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:sche

Jetty集群配置Session存储到MySQL、MongoDB

在Web开发中,Session表示HTTP服务器与客户端(例如浏览器)的"会话",每个客户端会有其对应的Session保存在服务器端,通常用来保存和客户端关联的一些信息,例如是否登录.购物车等. Session一般情况下是保存在服务器内存中.如果服务器重启,Session就会丢失.另外,如果是集群环境,一个Web应用部署在多台服务器上,一个用户多次请求可能会由不同的服务器来处理,Session如果保存在各自的服务器上,就无法共享了. 针对这个问题,Jetty服务器提供了用于集群环境下的

Eclipse上Maven环境配置使用 (全)

1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven. Maven下载地址: http://maven.apache.org/download.cgi 1.2 配置 Maven 的conf文件夹中配置文件settings.xml.  settings.xml 1.3 修改settings.xml,添加镜像服务器设置:    使用阿里云提供的Maven镜像服务器.     阿里云镜像服务器URL: ht

Maven settings配置中的mirrorOf

原文地址:http://blog.csdn.net/isea533/article/details/21560089 使用maven时,从来没仔细注意过setting配置节点的作用,直到今天配置总是不起作用,总是报错才开始去认识这些节点的含义. 这里就说mirrorOf,因为其他的怎么配置基本上都不会出错,只有mirrorOf会导致莫名其妙的错误,如果你还不了解mirrorOf,请往下看,你会认识到mirrorOf的重要作用的. 主要参考来自: Using Mirrors for Reposit

使用公司自己的maven服务器时,本地 maven 的配置方法

使用公司的maven服务器,可以加速jar包的下载. 如果要使用公司的maven服务器,需要对本地maven配置文件conf/settings.xml做相应修改,具体改法有两种. 一.mirror 方式 思路是利用 mirror 配置支持通配符号,于是可以指定所有的 repository 都去找公司的repository,如果有某些 repository 是公司没有的,就需要显示做排除. 这种方法明显的缺点就是要排除所有公司仓库中没有的repository. 具体配置如下 <mirrors>

开发流程和Maven的配置

按照何种开发模型? V模型:项目需求--->概要设计(功能模块) --->详细设计(页面的设计,数据库的设计) --->编码(框架的搭建,功能的实现)---->测试(单元测试,黑盒测试,性能测试,回归测试)--->发布(war包,jar包)--->项目评审--->项目完成 敏捷开发:快速迭代 数据库的设计的时候: 1.提取功能模块的名称. 用户,商品类别,商品,入库,出库,库存,供应商(公司信息) 每个功能模块会单独形成一张表. 2.根据每个表,形成它的字段(可以

Java-Maven(四):Eclipse集成Maven环境配置

一般maven都需要集成到IDE上使用的,而不是单独的使用,常见的maven可集成IDE:eclipse.IntelliJ IDEA.但这里就只学习eclipse集成maven的基础上,进行maven环境配置. eclipse的maven插件安装: 大多情况来说下载eclipse都默认已经集成了maven插件,验证是否集成eclipse菜单Window->Preferences 如果实在不行,可以在eclipse marketplace中查找maven,找到与当前eclipse版本一致的插件直接