在用spring-data-mongodb配置数据源的,执行相关数据库操作的时候报错,错误如下
org.springframework.data.mongodb.CannotGetMongoDbConnectionException: Failed to authenticate to database [ashop], username = [ashop], password = [g***********4] org.springframework.data.mongodb.core.ReflectiveDbInvoker.authenticate(ReflectiveDbInvoker.java:83) org.springframework.data.mongodb.core.MongoDbUtils.doGetDB(MongoDbUtils.java:127) org.springframework.data.mongodb.core.MongoDbUtils.getDB(MongoDbUtils.java:94) org.springframework.data.mongodb.core.SimpleMongoDbFactory.getDb(SimpleMongoDbFactory.java:203) org.springframework.data.mongodb.core.SimpleMongoDbFactory.getDb(SimpleMongoDbFactory.java:191) org.springframework.data.mongodb.core.MongoTemplate.getDb(MongoTemplate.java:1606) org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal(MongoTemplate.java:1839) org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1656) org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:564) org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:559) com.oneday.ashop.core.base.mongo.BaseMongoDaoSupport.findOne(BaseMongoDaoSupport.java:81) com.oneday.ashop.webgate.user.UserDao.findUser(UserDao.java:44) com.oneday.ashop.webgate.user.UserService.login(UserService.java:88) com.oneday.ashop.webgate.user.UserControl.login(UserControl.java:57) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)但是同样的地址、端口、数据库实例的名称、用户名、密码,用工具就能登陆上,
我的jar包版本是这样的:
然后的配置文件是这样的
如果有对这个比较了解,希望指导一下!
http://stackoverflow.com/questions/30112157/spring-mongodb-authorization-failed
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。