简体   繁体   中英

Spring Boot - JAVA_OPTS in application.properties for .bash_profile?

Have a Spring Boot Microservice as the following version:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
</parent>

Have the microservice setup as a jar file (which has an embedded tomcat container)...

Need to set JAVA_OPTS like this this:

JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses";

Can I set this in application.properties or does it need to be inside .bash_profile?

JAVA_OPTS is a common environment variable that can be optionally used by scripts within a shell. It is normally used to store preferred Java JVM system properties.

These properties need to be specified when the java command is executed.

java -jar app.jar -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses .

So, the question becomes, does the script that runs your spring boot application use this environment variable when executing your application? If the answer is no or you do not have a custom script then setting the environment variable will have no effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM