测试bootstrap.properties中的Spring Boot 2.2.4未加载包含的application.properties配置文件

时间:2020-01-29 10:51:09

标签: spring-boot

从2.1.6升级到Spring Boot版本2.2.4时,我遇到了问题。

问题方案:

我有一个使用<context type="Cinema.DAL.CinemaContext, Cinema">的Spring Boot测试,并将其作为活动配置文件进行测试。 public CinemaContext() : base("CinemaContext") { } 还包括由bootstrap-test.proeprties配置文件定义的其他一些配置文件。

下面是示例代码:

bootstrap-test.properties

此处application.properties中存在的属性未加载,并且测试失败。在spring-boot版本2.1.x上运行良好。新引导中有什么改变

版本?

如果我将@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT}) @ActiveProfiles("test") public class SampleTest { @Test public void sampleTest() { } } //bootstrap-test.properties spring.profiles.include=db 更改为application-db.properties,就可以正常工作。但是还是 我将需要引导文件,因为我具有Spring Cloud Config Server属性,需要在开始时进行加载。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

您使用的是哪个Spring Cloud版本?升级到引导2.2.4时,我们也遇到同样的问题。您应该使用启动2.2.4将spring cloud版本升级到<p>Image within container. Container is 500px wide, but image doesn't scale; it still maintains its intrinsic (original) width</p> <div class="container"> <img src="https://image.shutterstock.com/image-photo/white-transparent-leaf-on-mirror-260nw-1029171697.jpg"> </div> <p>Image within container. Container is 300px wide (smaller than the original image width, which is 381px), but image still shrinks to fit inside the container while displaying fully</p> <div class="container-two"> <img src="https://image.shutterstock.com/image-photo/white-transparent-leaf-on-mirror-260nw-1029171697.jpg"> </div> <p>Image not within container. Original image size (381px for the width)</p> <img src="https://image.shutterstock.com/image-photo/white-transparent-leaf-on-mirror-260nw-1029171697.jpg">