I basically have a bean in Spring that I wanted to activate only when 2 profiles are active. Basically, it would be like this:
@Profile({"Tomcat", "Linux"}) public class AppConfigMongodbLinux{...} @Profile({"Tomcat", "WindowsLocal"}) public class AppConfigMongodbWindowsLocal{...}
Therefore, I would like to use only AppConfigMongodbWindowsLocal when using -Dspring.profiles.active=Tomcat,WindowsLocal , but it is still trying to register AppConfigMongodbLinux .
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfigMongodbLinux': Injection of autowired dependencies failed
Is it possible to register a bean only if both profiles are active or am I using it incorrectly? :)
Thanks!!
Edit: sending a full stack.
The error is actually in a property that is missing from the properties, but is this a bean activated? I wanted to figure this out to make sure that I am not activating the wrong bean ..
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] ... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfigMongodbLinux': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.Integer mycompany.config.AppConfigMongodbLinux.mongoPort; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'mongo.port' in string value "${mongo.port}" ... 40 more Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.Integer mycompany.config.AppConfigMongodbLinux.mongoPort; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'mongo.port' in string value "${mongo.port}" ... Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'mongo.port' in string value "${mongo.port}"
source share