0

I am trying to run Spring Boot as a service using init.d. I face an issue that -Dspring.profiles.active=xxx is not being consider and spring says no active profiles found setting profile as default.

I am using SpringBoot version 1.5.13.

The below are my conf file settings

JAVA_OPTS="-Xms2048m -Xmx2048m -XX:+UseG1GC -XX:+UseStringDeduplication -Djsse.enableSNIExtension=false -Djava.security.egd=file:/dev/./urandom"
MODE=service
RUN_ARGS=-Dspring.profiles.active=myprofile

I even tried setting the environment variables RUN_ARGS but still the service does not pick it up.

My conf file is located in a different folder compared to my jar file and I have used the bootRepackage in my gradle build to point to the location(sample as below)

bootRepackage {
    mainClass = 'com.test.myapp.MyAppApplication'
    executable = true
    embeddedLaunchScriptProperties =
       [
         'mode': 'service',
         'confFolder': '/etc/myapp/conf'
        ]
    excludeDevtools = true
}

The name of my bootJar and the name of the conf file is same. Also I see the confFolder specified is taken correctly inside of the bootJar when I do a head -100 myapp.jar

I have used ospackage to bundle my spring boot application as a rpm and then I deploy it using yum install and start the service.

I am not sure what I am missing. Any help would be much appreciated.

Paranthaman
  • 41
  • 3
  • 8

2 Answers2

0

Instead of setting -Dspring.profiles.active to RUN_ARGS I set it to JAVA_OPTS and then the application ran as expected.

Paranthaman
  • 41
  • 3
  • 8
0

It worked for me by using

RUN_ARGS="--spring.profiles.active=production --spring.liquibase.enabled=false"

so, for you it should be

RUN_ARGS="--spring.profiles.active=myprofile"

Javi Vazquez
  • 517
  • 6
  • 21