具有Dropwizard指标的管理端口不起作用

时间:2013-07-16 21:49:42

标签: java eclipse maven metrics dropwizard

我正在关注DropWizard“Getting Started”教程,当我得到其他所有工作时,8081管理端口是空白的,并点击指标资源,线程资源和运行状况检查资源的任何超链接给我101错误。无法弄清楚为什么我几乎逐字逐句地跟着它。 如果有帮助,这是我的POM:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>DropWizard</groupId>
    <artifactId>DropWizard</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.yammer.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
            <version>0.6.2</version>
        </dependency>
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-core</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-servlets</artifactId>
            <version>3.0.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.6</version>
                <configuration>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.example.helloworld.HelloWorldService</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

2 个答案:

答案 0 :(得分:1)

想出来,有几点需要注意:

1)如果指定了dropwizard依赖项,则无需指定度量依赖项。

2)无论出于何种原因,8081端口都没有合作。当我将管理端口更改为9091时,一切都按预期工作。如果要更改端口,请在管理文件中指定以下内容:

http:
    port: 9090
    adminPort: 9091

我假设您可以使用您喜欢的任何端口,这些在我使用它们时恰好起作用。指定端口时,必须在http和之后出现的信息之间有一个选项卡。希望这有助于其他人避免我遇到的头发拉扯沮丧

答案 1 :(得分:0)

Dropwizard管理界面(截至0.6.2)仅与Metrics 2兼容。*。一旦发布,Dropwizard 0.7.0将与Metrics 3一起使用。