I think I have an easy one. I have the SpringBoot class, the usual one
@EnableAutoConfiguration
@EnableJpaRepositories(basePackages = { "co.com.jupiter.auctions.repositories" })
@SpringBootApplication(scanBasePackages = { "co.com.jupiter.autctions" })
and as an attribute, I have an autowired service that is null when tried to be used.
@Autowired private static ProfileService profileService;
This profileService in turn uses other autowired components. I tried to use this service inside this SpringBoot class initialization, and also inside the main method of this SpringBoot class. In both cases, this service is null.
I bet it has something to do with the lifecycle of SpringBoot, and the whole purpose of what I'm trying to do is to initialize certain parameters into memory once, just once, when the app initializes. This autowired goes to the database.
How could I do this if in this part of the SpringBoot app, dependency injection has not injected services yet?
When I do this in a controller, it works, services are already injected, but in a controller, it would go the database every time a request is done to this controller.
Thanks.