0

Azure loads startup details into the System.getenv() properties. I would like them to show up in the Environment variable from Spring.

How can I accomplish this?

As a side note, is there a way to add a system variable at startup (for testing?)

markthegrea
  • 3,731
  • 7
  • 55
  • 78

2 Answers2

1

you can add all your properties to application.properties in Spring Boot. otherwise, you can add a Bean in your spring boot application class that reads from the system properties & loads them.

  • I understand how I CAN add properties. I need to add System.getenv() properties. How do I add the bean? – markthegrea Jan 25 '18 at 19:21
  • if you weren't in a spring boot situation, you would possibly add a separate config class and annotate it with \@configuration. in your class annotated with \@SpringBootApplication you can also do the whole \@Bean annotation & do what you need to do there. –  Jan 25 '18 at 19:57
  • That is a great idea. Why would spring boot be a bottleneck? Do you have some code? I saw some yesterday here but the author deleted it! – markthegrea Jan 26 '18 at 18:04
  • i'm not saying it's a bottleneck at all. in spring boot by declaring a class a \@SpringBootApplication that means you can put \@Bean definitions in there. Otherwise, you'd have to do a separate class annotated with \@Configuration and do your bean definitions there. It's just a matter of how/where you declare your beans. You could also do a separate \@Configuration class with Spring Boot but that would be silly extra work as like I typed, you can do it straight up in the class annotated w\ \@SpringBootApplication –  Jan 27 '18 at 07:06
1

The actual answer to this question is "nothing". Spring boot automatically loads all the System.getenv() into the Environment variable at startup.

See: Spring Boot docs

And yes, I am a bit embarrassed.

markthegrea
  • 3,731
  • 7
  • 55
  • 78