Java dropwizard测试集成提供异常配置ParsingException

Java dropwizard测试集成提供异常配置ParsingException,java,mongodb,jetty,yaml,dropwizard,Java,Mongodb,Jetty,Yaml,Dropwizard,我目前正在使用framwork dropwizard embeddedmongo进行集成测试。但是当我执行测试时,我总是遇到这个异常 com.example.pointypatient.integration.PointyPatientApplicationTest Time elapsed: 3.054 sec <<< ERROR! java.lang.RuntimeException: io.dropwizard.configuration.ConfigurationP

我目前正在使用framwork dropwizard embeddedmongo进行集成测试。但是当我执行测试时,我总是遇到这个异常

com.example.pointypatient.integration.PointyPatientApplicationTest  Time elapsed: 3.054 sec  <<< ERROR!
java.lang.RuntimeException: io.dropwizard.configuration.ConfigurationParsingException: dropwizard-angular- example-master\target\test-classes\integration.yml has an error:Configuration at dropwizard-angular-example-master\target\test-classes\integration.yml must not be empty
感谢您提供的任何帮助,仅当
ObjectMapper
中的方法
readTree
返回null时才会引发此异常

  • 查看传递给
    build
    方法的
    ConfigurationSourceProvider
    派生类,因为它没有正确处理
    IOException
    (我可以假设您使用的是模拟类)
  • 查看
    path
    参数,似乎您应该传递“dropwizard angular-example master\target\test classes\integration.yml”而不是“dropwizard angular example master\target\test classes\integration.yml”*第一条路径在dropwizard angular-之后有一个空格

如果dropwizard配置文件(即
integration.yml
)位于
test/resources
目录中,则无需使用
ResourceHelpers.resourceFilePath(“integration.yml”)
将完整配置路径作为参数传递到
DropwizardAppExtension
,只需传递其名称(例如“integration.yml”)

私有静态DropwizardAppExtension规则=新建DropwizardAppExtension(
MyDropwizardApplication.class,“integration.yml”);
dbConfig:
  host: localhost
  port: 12345
  dbName: test

server:
  applicationConnectors:
    - type: http
      port: 8080
    - type: https
      port: 8443
      keyStorePath: example.keystore
      keyStorePassword: example
      validateCerts: false
  adminConnectors:
    - type: http
      port: 8081
    - type: https
      port: 8444
      keyStorePath: example.keystore
      keyStorePassword: example
      validateCerts: false

# Logging settings.
logging:
  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
  level: INFO

  appenders:
    - type: console
private static DropwizardAppExtension<MyDropwizardConfiguration> RULE = new DropwizardAppExtension<>(
            MyDropwizardApplication.class, "integration.yml");