title: Springboot does not find environment variables when run as a systemd service
body: <p>I have a springboot app that I run as a systemd service. My systemd app service file looks like this:</p>
  <pre><code>[Unit]
  Description=app name
  After=syslog.target
  
  [Service]
  EnvironmentFile=/etc/environment
  User=springboot
  ExecStart=&quot;/opt/jar-folder-name/app-name.jar&quot;
  SuccessExitStatus=143
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  <p>In the /etc/environment file there's an environment variable specified:</p>
  <blockquote>
  <p>SOME_ENV_VAR=SOME_VALUE.THAT_CONTAINS_STUFF</p>
  </blockquote>
  <p>In my springboot app, I try to access the environment variable with <em>System.getenv</em> method:</p>
  <pre><code>    @Bean
      public SomeBean someBean() {
        System.out.println(&quot;SOME_ENV_VAR was: &quot;);
        System.out.println(System.getenv(&quot;SOME_ENV_VAR&quot;));
        return new ServiceX(System.getenv(&quot;SOME_ENV_VAR&quot;));
      }
  </code></pre>
  <p>In my server this prints out:</p>
  <blockquote>
  <p>SOME_ENV_VAR was:
  null</p>
  </blockquote>
  <p>Locally on my own machine, when I run the springboot with <em>mvn spring-boot:run</em> it finds the environment variable and nicely prints it out. I also tested that in the server if I run the env command in terminal, the environment variable defined in /etc/environment is found.</p>
  <p>So how to get springboot to detect the environment variable when springboot app is being run as a systemd service?</p>
  <p>My springboot version: 2.3.0
  Server OS: Ubuntu 18</p>
  <p>Im using ansible systemd module to restart the application and service:</p>
  <pre><code>---
  - name: &quot;Restart application&quot;
    systemd:
      name: &quot;{{ springboot_application_name }}.service&quot;
      enabled: yes
      daemon-reload: yes
      state: restarted
  </code></pre>