- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Spring Boot 应用程序中引入了配置文件,并将一些属性从 application.properties 移到了 application-puppet.properties。这在运行应用程序时效果很好,但在测试时却不行。
将此添加到 application.properties 文件:
spring.profiles.active=puppet
并将一个属性从 application.properties 移动到 application-puppet.properties
person.fileName=person.txt
然后我将@ActiveProfiles 添加到抽象测试类:
@ContextConfiguration(classes = AbstractElasticsearchSpringContextTests.EsConfig.class)
@ActiveProfiles("puppet")
public abstract class AbstractElasticsearchSpringContextTests extends AbstractTestNGSpringContextTests {
...
但是我得到这样的错误:嵌套异常是 java.lang.IllegalArgumentException:无法解析字符串值“${person.fileName}”中的占位符“person.fileName”
最佳答案
您可以在 ContextConfiguration 注释中添加 SpringBootContextLoader 作为加载器:
@ContextConfiguration(classes = {AbstractElasticsearchSpringContextTests.EsConfig.class}, loader = SpringBootContextLoader.class)
它将处理您的 Activity 配置文件属性文件。
关于java - @ActiveProfiles 不适用于 AbstractTestNGSpringContextTests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35890997/
我有一个 TestNG 类,如下所示: public class WebAPITestCase extends AbstractTestNGSpringContextTests{.....} 我试图理
我在 Spring Boot 应用程序中引入了配置文件,并将一些属性从 application.properties 移到了 application-puppet.properties。这在运行应用程
具有多个 AbstractTestNGSpringContextTests 类的 Spring Boot TestNG 会初始化每个测试类的 Spring Boot 上下文。 我已经定义了多个 Tes
我的测试已经扩展了一个抽象的 BaseIntegrationTest 类,因此无法扩展 AbstractTestNGSpringContextTests 类 - 正如我们通常对 Testng Spri
我是一名优秀的程序员,十分优秀!