我正在尝试运行基于配置文件的测试。我已经在我的配置文件中设置了默认配置文件,但测试看不到它。SeleniumSpring Bootpom不确定我是否缺少任何配置。命令(执行测试):mvn 测试 -Dspring.profiles.active=谷歌 - 工作正常mvn 测试 - Dspring.profile.active=酱油实验室 - 工作正常mvn 测试 - 错误(如下所示)错误Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'base.url' in value "${base.url}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) ~[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]
2 回答
青春有我
TA贡献1784条经验 获得超8个赞
如果未指定任何截面梁,Spring 将激活默认截面梁。对于默认配置文件,它会扫描文件中的配置值。因此,您需要执行以下操作:application.properties
创建文件
application.properties
加
base.url=<url for default profile>
之后,它应该工作正常。
侃侃无极
TA贡献2051条经验 获得超10个赞
您需要启用资源筛选
<build>
<resources>
<resource>
<directory>src/test/resources/</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
添加回答
举报
0/150
提交
取消