简体   繁体   中英

Is bootstrap.yml required?

I have a test class annotated with

@SpringBootTest.
@ActiveProfiles("default")

There was originally a bootstrap.yml file with the following contents

spring:
  application:
    name: [insert name]
  cloud:
    config:
      enabled: false
    vault:
      enabled: false

I would like to move the contents of bootstrap.yml into application-default.yml and delete bootstrap.yml, but this causes the tests to fail. Is this something that is possible?

Try to use this annotation:

@TestPropertySource(locations = "classpath:application-default.yml")

Just make sure that your application-default.yml is on resource paste.

edit: take a look https://stackoverflow.com/a/26840503/11329776

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM