繁体   English   中英

maven 系统变量和操作系统依赖

[英]maven system variable and operating system dependency

我有文件 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>xxx</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>5.5.2</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <systemPropertyVariables>                            <application.properties>/application.properties</application.properties>
                        <web.a>${settings.localRepository}</web.a>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

我使用两个操作系统和不同的 IDEA:首先:

Ubuntu 18.04
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
javac 1.8.0_232
IntellijIDEA community edition 2019.3.3

第二个实例:

VirtualBox Windows 7
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
javac 1.8.0_231
Eclipse IDEA for Enterprise Java Developers 2019-09 R (4.13.0)

文件 pom.xml 有系统属性变量:

<web.a>${settings.localRepository}</web.a>

我在项目中使用代码:

@Test
    public void properties()
    {
        Properties props = System.getProperties();

        for(Map.Entry prop :props.entrySet())
        {
            System.out.println(prop.getKey()+" "+prop.getValue());
        }
    }

当我在第一个实例中部署和运行构建时,变量被加载到 jvm 中,但在第二个实例的同一个构建中不会发生加载。

谁能告诉:是什么原因?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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