举个例子:java
$JAVA_ARGS.=“-Dresin.home=$SERVER_ROOT-server -Xms2048M-Xmx2048M-Xmn512M-XX:PermSize=256M -XX:MaxPermSize=256M-XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=7-XX:GCTimeRatio=19 -Xnoclassgc-Xloggc:log/gc.log-XX:+PrintGCDetails -XX:+PrintGCTimeStamps-XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0”
这是JVM参数调优时候的一些配置spring
java的System.getProperty()方法默承认以获取的值:apache
| Key | Value|架构
| Java.version | Java 运行时环境版本|jvm
| java.vendor | Java 运行时环境供应商 |maven
|java.vendor.url|Java 供应商的 URL|spring-boot
|java.home|Java 安装目录|ui
|java.vm.specification.version|Java 虚拟机规范版本|url
|java.vm.specification.vendor|Java 虚拟机规范供应商|操作系统
|java.vm.specification.name|Java 虚拟机规范名称|
|java.vm.version|Java 虚拟机实现版本|
|java.vm.vendor|Java 虚拟机实现供应商|
|java.vm.name|Java 虚拟机实现名称|
|java.specification.version|Java 运行时环境规范版本|
|java.specification.vendor|Java 运行时环境规范供应商|
|java.specification.name|Java 运行时环境规范名称|
|java.class.version|Java 类格式版本号|
|java.class.path|Java 类路径|
|java.library.path|加载库时搜索的路径列表|
|java.io.tmpdir|默认的临时文件路径|
|java.compiler|要使用的 JIT 编译器的名称|
|java.ext.dirs|一个或多个扩展目录的路径|
|os.name|操做系统的名称|
|os.arch|操做系统的架构|
|os.version|操做系统的版本|
|file.separator|文件分隔符(在 UNIX 系统中是“/”)|
|path.separator|路径分隔符(在 UNIX 系统中是“:”)|
|line.separator|行分隔符(在 UNIX 系统中是“/n”)|
|user.name|用户的帐户名称|
|user.home|用户的主目录|
|user.dir|用户的当前工做目录|
public class AutoKeyConfig { public static final String AUTOKEY_PORT = "sword.autokey.port"; public static final int PORT_DEFAULT = 8204; }
实现代码:
String portStr = SwordConfigLoader.getProperty(AutoKeyConfig.AUTOKEY_PORT); int port = portStr != null ? Integer.parseInt(portStr) : AutoKeyConfig.PORT_DEFAULT;
<build> <sourceDirectory>src/main/scala</sourceDirectory> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <configuration> <launchers> <launcher> <id>pdata</id> <mainClass>com.pdata.PDataApplication</mainClass> <!-- args are optional --> <!--<args>--> <!--<arg>arg1</arg>--> <!--</args>--> <!-- jvmArgs are optional --> <jvmArgs> <jvmArg>-Xmx1024m</jvmArg> <jvmArg>-Dsword.autokey.port=9202</jvmArg> </jvmArgs> </launcher> <!-- you could define other launcher --> </launchers> </configuration> <executions> <execution> <id>compile-and-test-compile</id> <goals> <goal>compile</goal> <goal>testCompile</goal> <goal>run</goal> </goals> </execution> <execution> <id>doc</id> <phase>install</phase> <goals> <goal>doc</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> </execution> </executions> <configuration> <includeScope>system</includeScope> <!--<outputDirectory>${project.build.directory}/${project.build.finalName}/lib</outputDirectory>--> </configuration> </plugin> </plugins> </build>
这样,就能够直接使用以下命令动态注入sword.autokey.prot的值, 启动应用:
mvn scala:run -Dlauncher=pdata