springmavenservicespring-bootinit.d

Add additional parameters to Spring Boot app


I am wondering if it's possible to add spring's additional parameters such as -Dspring.profiles.active=prod to spring boot app in case of running it as a service.

I checked the script that was generated automatically by spring-boot-maven-plugin:

command="$javaexe -jar -Dsun.misc.URLClassPath.disableJarChecking=true $jarfile $@"

so maybe it can be done via maven plugin's options, but couldn't find any except of JVM arguments which is not so useful...


Solution

  • I couldn't find any solution including the one I described in question - it seems that plugin's additional params also don't work.

    At the end I solved it by using systemd service approach.

    Looks like that and works perfectly:

    [Unit]
    Description=Some app
    After=syslog.target
    
    [Service]
    ExecStart=java -Dspring.profiles.active=production -jar /home/apps/monitoring-app-1.0.0.jar
    
    [Install]
    WantedBy=multi-user.target