Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何配置带账号密码的mongodb? #2

Closed
tuxknight opened this issue Sep 12, 2016 · 2 comments
Closed

如何配置带账号密码的mongodb? #2

tuxknight opened this issue Sep 12, 2016 · 2 comments

Comments

@tuxknight
Copy link

tuxknight commented Sep 12, 2016

mongodb.url里只填mongodb的IP:Port才能够正常启动。

对于配置有数据库账号和密码的mongodb,使用mongodb://user:pass@mongodb:27017 这样的地址配置时,camel启动会抛异常。
建议优化配置方式。

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'virtualServerDaoImpl' defined in file [/usr/local/apache-tomcat-7.0.62/webapps/ROOT/WEB-INF/classes/com/dianping/phoenix/lb/dao/impl/VirtualServerDaoImpl.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.dianping.phoenix.lb.dao.ModelStore]: : Error creating bean with name 'mongoModelStoreImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplateConfig' defined in class path resource [spring/applicationContext-mongo.xml]: Cannot resolve reference to bean 'dbConfig' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbConfig': Cannot resolve reference to bean 'mongo' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongo': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'com.mongodb.ServerAddress[]' for property 'replicaSetSeeds'; nested exception is java.lang.IllegalArgumentException: Could not resolve at least one server of the replica set configuration! Validate your config!; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoModelStoreImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplateConfig' defined in class path resource [spring/applicationContext-mongo.xml]: Cannot resolve reference to bean 'dbConfig' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbConfig': Cannot resolve reference to bean 'mongo' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongo': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'com.mongodb.ServerAddress[]' for property 'replicaSetSeeds'; nested exception is java.lang.IllegalArgumentException: Could not resolve at least one server of the replica set configuration! Validate your config!

@leonindy
Copy link
Contributor

你好,camel使用spring MongoDB驱动连接MongoDB,如果有用户名和密码,请配置spring配置文件:
camel-admin/src/main/resources/spring/applicationContext-mongo.xml,添加用户名和密码。

建议把用户名和密码配置在本地文件/data/appdatas/camel/mongo.properties,spring会从中读取配置。

具体请参考spring官方文档:http://projects.spring.io/spring-data-mongodb/

@tuxknight
Copy link
Author

THX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants