我正在尝试使用 Coda Hale 的 metrics-jetty 项目:http: //metrics.codahale.com/manual/jetty/
问题是,我真的不知道如何配置码头来使用这些类。
我将项目添加到我的 pom.xml 中,但是在使用 jetty.xml 时:
<Call name="addConnector">
<Arg>
<New class="com.yammer.metrics.jetty.InstrumentedSelectChannelConnector">
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="9090"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
(从jetty-distribution复制),我收到此错误:
Caused by: java.lang.ClassNotFoundException: com.yammer.metrics.jetty.InstrumentedSelectChannelConnector
编辑
直接在 jetty-maven-plugin 中执行此操作具有相同的效果:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
<reload>manual</reload>
<connectors>
<connector
implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
</connector>
<connector
implementation="com.yammer.metrics.jetty.InstrumentedSelectChannelConnector">
</connector>
</connectors>
<webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
<!-- <jettyXml>${project.basedir}/src/main/resources/jetty.xml</jettyXml> -->
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
提前感谢比约恩