A simple spring boot jar package enabling script under ubuntu

For example, there is environment variable configuration in a java program, you need to modify the environment variable before starting, such as:

#!/bin/sh

export TEST_ENV=ddddddddd

java  -jar demo4.jar

The corresponding java code is as follows:

application.properties

test-env=${TEST_ENV:hello}

java

@RestController
@RequestMapping("/v1/ops")
public class DebugController {

    @Value("${test-env}")
    private String ENV;

    @GetMapping("/env")
    public String testEnv() {
        return ENV;
    }
}

test:

Guess you like

Origin blog.csdn.net/wuzhong8809/article/details/107186643