弹簧 - 多个型材处于活动状态
我基本上在春天有一个豆子,我只想在2个配置文件处于活动状态时才激活它。基本上,它就像:
@Profile({"Tomcat", "Linux"})
public class AppConfigMongodbLinux{...}
@Profile({"Tomcat", "WindowsLocal"})
public class AppConfigMongodbWindowsLocal{...}
所以我希望当我使用时,它会尝试只使用,但它仍然尝试注册.-Dspring.profiles.active=Tomcat,WindowsLocal
AppConfigMongodbWindowsLocal
AppConfigMongodbLinux
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfigMongodbLinux': Injection of autowired dependencies failed
是否可以仅在两个配置文件都处于活动状态时才注册 Bean,或者我错误地使用它?:)
谢谢!!
编辑:发布整个堆栈。
错误实际上发生在属性上缺少的属性上,但是这个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}"