簡體   English   中英

Maven surefire插件不會注入系統屬性

[英]maven surefire plugin does not inject system properties

這就是我設置值的方式

   <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <systemProperties>
                        <property>spring.active.profiles</property>
                        <value>Test</value>
                    </systemProperties>
                    <systemPropertyVariables>
                        <spring.active.profiles>development</spring.active.profiles>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

測試失敗

@Test
public void testGetProfile() throws Exception {
    assertEquals("development", System.getProperty("spring.active.profiles"));
}

我懂了

java.lang.AssertionError: 
Expected :development
Actual   :null

我在這里想念什么?

沒有什么不對!

在控制台mvn測試中運行

要么

Eclipse-> [項目]->運行方式-> Maven測試

如果通過Eclipse->運行方式-> JUnit運行該測試,則可能會失敗,有時此操作會忽略pom.xml變量。

我的問題是,插件位於另一個要測試的模塊中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM