Java System Property

本文详细介绍了Java运行时环境中各类系统属性的含义与作用,包括Java版本、虚拟机配置、操作系统信息及路径设置等内容,为开发者提供了全面的参考。
  1. java.version            Java Runtime Environment version  
  2. java.vendor            Java Runtime Environment vendor  
  3. java.vendor.url            Java vendor URL  
  4. java.home            Java installation directory  
  5. java.vm.specification.version                    Java Virtual Machine specification version  
  6. java.vm.specification.vendor                    Java Virtual Machine specification vendor  
  7. java.vm.specification.name                    Java Virtual Machine specification name  
  8. java.vm.version            Java Virtual Machine implementation version  
  9. java.vm.vendor            Java Virtual Machine implementation vendor  
  10. java.vm.name            Java Virtual Machine implementation name  
  11. java.specification.version                Java Runtime Environment specification version  
  12. java.specification.vendor             Java Runtime Environment specification vendor  
  13. java.specification.name        Java Runtime Environment specification name  
  14. java.class .version                        Java  class  format version number  
  15. java.class .path                  Java  class  path  
  16. java.library.path                        List of paths to search when loading libraries  
  17. java.io.tmpdir                Default temp file path  
  18. java.compiler            Name of JIT compiler to use  
  19. java.ext.dirs            Path of extension directory or directories  
  20. os.name                Operating system  name  
  21. os.arch                Operating system  architecture  
  22. os.version            Operating system  version  
  23. file.separator            File separator ("/"  on UNIX)  
  24. path.separator            Path separator (":"  on UNIX)  
  25. line.separator            Line separator ("\n"  on UNIX)  
  26. user.name            User's account name  
  27. user.home            User's home directory  
  28. user.dir                User's current working directory  
### 关于 Maven POM 文件中的 `systemProperty` 配置 在 Maven 构建过程中,可以通过多种方式配置系统属性(System Properties),其中一种常见的方式是在插件中使用 `<systemProperties>` 或者 `<systemPropertyVariables>` 来传递这些属性。需要注意的是,在标准的 Maven Super POM 中并没有直接提供 `<systemProperty>` 标签作为全局配置项[^2]。 #### 使用 Surefire 插件配置 System Property Maven 的 Surefire 插件常用于运行单元测试,并支持通过其配置来指定系统属性。以下是具体的配置方法: ```xml <project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M7</version> <configuration> <systemPropertyVariables> <propertyName>propertyValue</propertyName> <!-- 可以继续添加其他系统属性 --> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> </project> ``` 在此示例中,`<systemPropertyVariables>` 被用来定义一系列键值对形式的系统属性。例如,上面的例子设置了名为 `propertyName` 的系统属性,其值为 `propertyValue`[^1]。 #### 在 `<properties>` 中定义并引用系统属性 除了通过插件配置外,还可以利用 POM 文件中的 `<properties>` 定义变量,并将其应用于构建过程的不同部分。虽然这种方式本身不涉及 `<systemProperty>` 标签,但它可以间接影响系统的某些行为。 ```xml <project> <properties> <jdbc.url>jdbc:mysql://localhost:3306/maven</jdbc.url> </properties> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>com.example.MainApp</mainClass> <systemProperties> <systemProperty> jdbc.url=${jdbc.url} </systemProperty> </systemProperties> </configuration> </plugin> </plugins> </build> </project> ``` 在这个例子中,`${jdbc.url}` 是从 `<properties>` 中获取的值,并被赋给系统属性 `jdbc.url`[^1]。 #### 总结 尽管 Maven 并未直接提供 `<systemProperty>` 标签供全局使用,但通过插件如 `maven-surefire-plugin` 和 `exec-maven-plugin`,能够灵活地管理与应用系统属性。此外,借助 `<properties>` 定义项目范围内的变量也是一种有效的替代方案。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值