[英]Dropwizard: Failed to parse configuration at: logging.appenders
當我使用“java -jar target\helloDropwizard-1.0-SNAPSHOT.jar 服務器”運行基本 Dropwizard.io (v0.8.1) 項目時,出現錯誤“無法解析配置:logging.appenders”。
完整的錯誤信息:
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>
我需要將ServiceResourceTransformer添加到陰影插件中。
<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>
查看更多信息:
此問題的正確解決方案是在 META-inf 文件中添加附加程序。
參見https://www.dropwizard.io/en/stable/manual/core.html#logging
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.