I want to execute several customization methods in my Spring context.
I currently have the following code, but it does not work, as I say that they beansdo not have a return type either.
@Configuration
@Component
public class MyServerContext {
...
@Bean
public UserData userData() {
UserData userData = new AWSUserDataFetcher(urlUtil()).fetchUserData();
return userData;
}
@Bean
public void setupKeyTrustStores() {
System.setProperty(SYS_TRUST_STORE, userData().get(TRUST_STORE_PATH));
System.setProperty(SYS_TRUST_STORE_PASSWORD, userData().get(TRUST_STORE_PASSWORD));
System.setProperty(SYS_KEY_STORE, userData().get(KEY_STORE_PATH));
System.setProperty(SYS_KEY_STORE_PASSWORD, userData().get(KEY_STORE_PASSWORD));
System.setProperty(ENABLE_SNI_EXTENSION, "false");
}
...
}
How to run this method automatically in context @Configurationwithout annotation @Bean?
source
share