Dropwizard:无法在以下位置解析配置:logging.appenders

时间:2015-05-30 03:53:55

标签: java maven dropwizard maven-shade-plugin

我收到错误"无法解析配置:logging.appenders"当我使用" java -jar target \ helloDropwizard-1.0-SNAPSHOT.jar服务器运行基本的Dropwizard.io(v0.8.1)项目"。

完整的错误消息:

Failed to parse configuration at: logging.appenders.[0]; 
Could not resolve type id 'console' into a subtype of [simple type, class io.dropwizard.logging.AppenderFactory]: known type ids = [AppenderFactory] at [Source: N/A; line: -1, column: -1] (through reference chain: io.dropwizard.
Configuration["logging"]->io.dropwizard.logging.LoggingFactory["appenders"]->java.util.ArrayList[0])

我的pom.xml

<properties>
    <dropwizard.version>0.8.1</dropwizard.version>
</properties>

<dependencies>

    <!-- Dropwizard -->
    <dependency>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-core</artifactId>
        <version>${dropwizard.version}</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <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.ManifestResourceTransformer">
                                <mainClass>com.hello.helloDropwizard.App</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:5)

我需要将ServiceResourceTransformer添加到shade-plugin。

<executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>com.hello.helloDropwizard.App</mainClass>
                </transformer>
                <!-- SEE HERE!!!! -->
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <!-- -->
            </transformers>
        </configuration>
    </execution>
</executions>

查看更多信息: