Java – why does the dropwizard configuration not work?
•
Java
Recently, I changed the dropwizard version of HVDF project from 0.6 2 to 0.8 2. Once I try to run the application, I get the following error I provide the following configuration classes and YML files:
Configuration class:
package com.mongodb.hvdf;
import io.dropwizard.Configuration;
import java.util.LinkedHashMap;
import java.util.Map;
import com.mongodb.hvdf.configuration.MongoGeneralConfiguration;
public class HVDFConfiguration extends Configuration {
public MongoGeneralConfiguration mongodb = new MongoGeneralConfiguration();
public Map<String,Object> services = new LinkedHashMap<String,Object>();
}
Yaml file:
server:
applicationConnectors:
- type: http
port: 8080
I received the following error while running:
config.yml has an error: * Failed to parse configuration at: server.applicationConnectors.[0]; Could not resolve type id 'http' into a subtype of [simple type,class io.dropwizard.jetty.ConnectorFactory] at [Source: N/A; line: -1,column: -1] (through reference chain: com.mongodb.hvdf.HVDFConfiguration["server"]->io.dropwizard.server.DefaultServerFactory["applicationConnectors"]->java.util.ArrayList[0])
Solution
If you are using Maven shade plug-in, please use the necessary transformer
Adding services resource transformer to your shade plug-in configuration may solve the problem Read more about transformers (here)
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.yb.exercise.dw.App</mainClass>
</transformer>
</transformers>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
