Dropwizard配置不使用阴影罐

时间:2018-03-28 01:19:44

标签: java rest dropwizard dropwizard-templates

尝试在configuration.yaml文件中运行带有属性的着色jar时,我遇到以下问题。 (当直接运行主类时没有发生)

运行命令:java -jar target/mlsdata-1.0.jar server configuration.yaml

ERROR:

io.dropwizard.configuration.ConfigurationParsingException: configuration.yaml has an error:
  * Failed to parse configuration at: server.applicationConnectors.[0]; Could not resolve type id 'http' as a subtype of [simple type, class io.dropwizard.jetty.ConnectorFactory]: known type ids = [] (for POJO property 'applicationConnectors')
 at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.zaplabs.MlsConfiguration["server"]->io.dropwizard.server.DefaultServerFactory["applicationConnectors"]->java.util.ArrayList[0])

根据我从各种来源的理解,它可能是一个maven包装问题。解决方案对我没有帮助。

这是我在POM中的构建设置。

`         

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.zaplabs.MlsApplication</mainClass>
                    </manifest>
                </archive>
                <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>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <classpathPrefix>lib/</classpathPrefix>
                                <mainClass>com.zaplabs.MlsApplication</mainClass>
                            </manifest>
                        </archive>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.zaplabs.MlsApplication</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

`

Dropwizard版本:

    <dependency>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-core</artifactId>
        <version>1.3.0</version>
    </dependency>

Configuration.yaml

server:
  applicationConnectors:
    - type: http
      port: 9000
  adminConnectors:
    - type: http
      port: 9001

# Database settings.
database:
    # the name of the JDBC driver, mysql in our case
    driverClass: com.mysql.jdbc.Driver
    # the username
    user: xxx
    # the password
    password: xxx
    # the JDBC URL
    url: jdbc:mysql://xxx
    properties:
      charSet: UTF-8
      maxWaitForConnection: 1s
      validationQuery: "/* MyService Health Check */ SELECT 1"
      minSize: 8
      maxSize: 32
      checkConnectionWhileIdle: false
      evictionInterval: 10s
      minIdleTime: 1 minute
      hibernate.dialect: org.hibernate.dialect.H2Dialect
      hibernate.show_sql: true
      hibernate.generate_statistics: false
      hibernate.hbm2ddl.auto: validate # validates schema when service is started

1 个答案:

答案 0 :(得分:1)

所以我有同样的问题,我找到了解决方案here

我还必须使用以下插件

ggplot(dat, aes(x = Axis)) + 
  geom_col(aes(y = V1), fill = "darkred", alpha = .5, width=0.4) + 
  geom_col(aes(y = V2), fill = "blue", alpha = .5, 
           position = position_nudge(x = 0.4),width=0.4) + 
  geom_line(aes(y = V3, group = NA))