springboot 打jar包 配置启动参数,指定配置文件路径、名字,配置端口号、配置IP

    xiaoxiao2023-10-21  172

    java -jar projectName.jar --spring.config.location=D:\JavaSoft\myapplication.properties --port=1231 --address=127.0.0.1

    这"-server"用于设置虚拟机使用何种运行模式,一般有两种,

    1、client模式。启动比较快,但运行时性能和内存管理效率不如server模式,通常用于客户端应用程序。

    2、server模式。启动比client慢,但可获得更高的运行性能。 

    “--spring.config.location” 指定配置文件路径,不写使用默认加载路径的application.properties

     

    此外 “--port” “--address”为设置端口号和IP。而且myapplication.properties我是这样写的,然后才能用--port --address。(一般不像我这样写,直接用-Dserver.port=8080   -Dserver.address=127.0.0.1既可)

     

     

     

    最新回复(0)