Spring boot running a fully executable JAR and specify -D properties

后端 未结 2 1963
陌清茗
陌清茗 2020-12-09 10:00

The Spring Boot Maven and Gradle plugins can now generate full executable archives for Linux/Unix operating systems.Running a fully executable JAR is as easy as typing:

2条回答
  •  既然无缘
    2020-12-09 10:23

    There are two ways to configure properties like that:

    1:

    By specifying them in a separate configuration file. Spring Boot will look for a file named like JARfilename.conf which should be stored in the same folder like the JAR file. There you can add the environment variable JAVA_OPTS:

    JAVA_OPTS="-Dpropertykey=propvalue"
    

    2:

    Or you can just specify the value for the environment variable in the shell before you execute the application:

    JAVA_OPTS="-Dpropertykey=propvalue" ./myapp.jar
    

    Have a look at the documentation for the complete list of available variables: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#deployment-service

    Regarding your second question: To execute a JAR, you don't need a JDK, a JRE is sufficient (but you need at least that, if you don't have any java installed on the server, the application won't run).

提交回复
热议问题