Springboot 启动方式配置

作者: Owater | 来源:发表于2017-06-12 17:04 被阅读2807次

使用Linux服务的方式启动、停止、重启

pom.xml文件配置,注意 <executable>true</executable>

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <executable>true</executable>
    </configuration>
</plugin>

配置Linux服务,不用在root环境下配置

sudo ln -s /opt/myapp/myapp.jar /etc/init.d/myapp

给jar配置执行权限

chmod +x myapp.jar

启动服务

sudo service myapp start

自定义参数启动方式配置(更多配置参数,可以上官网)
RUN_ARGS是携带入参给程序
在jar同级目录下创建myapp.conf文件,配置如下信息

JAVA_OPTS=-Xmx1024M
LOG_FOLDER=/opt/log
RUN_ARGS=--spring.profiles.active=RUN_JOB

将服务配置成系统服务,随服务器启动而启动 (可选项)

[Unit]
Description=myapp
After=syslog.target

[Service]
User=myapp
ExecStart=/opt/myapp/myapp.jar
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Springboot官网配置

相关文章

网友评论

    本文标题:Springboot 启动方式配置

    本文链接:https://www.haomeiwen.com/subject/btwlqxtx.html