我有一个Jhipster Spring引导项目。最近,我从mlabs独立沙箱转向了Atlas集群沙箱、M0免费层副本集。它甚至起作用了,我对它做了一些数据库操作。但是现在由于某种原因,出现了一个读取权限错误。
Error creating bean with name 'mongobee' defined in class path resource [DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoQueryException: Query failed with error code 8000 and error message 'user is not allowed to do action [find] on [test.system.indexes]' on server ********-shard-00-01-mfwhq.mongodb.net:27017您可以在这里看到完整的堆栈,https://pastebin.com/kaxcr7VS
我到处搜索,我所能找到的就是M0层用户没有覆盖管理数据库的权限,而我没有这样做。
即使现在连接到Mlabs,DB也可以正常工作,但是在阿特拉斯DB M0层上有这个问题。
Mongo DB版本: 3.4
Jars和它的版本名称:‘mongo蜜蜂’,版本:'0.10‘名称:’mongobee驱动程序‘,版本:'3.4.2’
@Neil,我用来连接的userId是admin,连接通过shell或Robo3T(mongo )读写工作。
发布于 2018-04-23 09:04:13
经过与MongoDB支持团队的讨论,MongoDB 3.0反对直接访问system.indexes集合,该集合以前用于列出数据库中的所有索引。应用程序应该使用db.<COLLECTION>.getIndexes()。
从MongoDB图集文档可以看出,它们可能禁止对system.集合的调用:
另外,对于read和readWrite角色,也可以指定一个集合。如果没有为read和readWrite指定集合,则角色将应用于所有集合(不包括某些系统)。集合)在数据库中。
从堆栈跟踪中可以看到,MongoBee正在尝试进行此调用,因此现在是库问题,应该进行更新。
UPDATE:为了在MongoBee发布新版本之前修复问题:
git clone git@github.com:mongobee/mongobee.git,cd mongobee的最新来源git fetch origin pull/87/head:mongobee-atlasgit checkout mongobee-atlasmvn clean install/target文件夹或本地/.m2获取已编译的jar发布于 2018-04-24 04:08:52
今早偶然发现了这个问题。这里有一个快速而肮脏的猴子补丁来解决这个问题:
package com.github.mongobee.dao;
import com.github.mongobee.changeset.ChangeEntry;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.util.List;
import static com.github.mongobee.changeset.ChangeEntry.CHANGELOG_COLLECTION;
public class ChangeEntryIndexDao {
public void createRequiredUniqueIndex(DBCollection collection) {
collection.createIndex(new BasicDBObject()
.append(ChangeEntry.KEY_CHANGEID, 1)
.append(ChangeEntry.KEY_AUTHOR, 1),
new BasicDBObject().append("unique", true));
}
public DBObject findRequiredChangeAndAuthorIndex(DB db) {
DBCollection changelogCollection = db.getCollection(CHANGELOG_COLLECTION);
List<DBObject> indexes = changelogCollection.getIndexInfo();
if (indexes == null) return null;
for (DBObject index : indexes) {
BasicDBObject indexKeys = ((BasicDBObject) index.get("key"));
if (indexKeys != null && (indexKeys.get(ChangeEntry.KEY_CHANGEID) != null && indexKeys.get(ChangeEntry.KEY_AUTHOR) != null)) {
return index;
}
}
return null;
}
public boolean isUnique(DBObject index) {
Object unique = index.get("unique");
if (unique != null && unique instanceof Boolean) {
return (Boolean) unique;
} else {
return false;
}
}
public void dropIndex(DBCollection collection, DBObject index) {
collection.dropIndex(index.get("name").toString());
}
}发布于 2018-05-03 23:14:54
Caused by: java.lang.NoSuchMethodError: com.github.mongobee.dao.ChangeEntryIndexDao.<init>(Ljava/lang/String;)V
at com.github.mongobee.dao.ChangeEntryDao.<init>(ChangeEntryDao.java:34)
at com.github.mongobee.Mongobee.<init>(Mongobee.java:87)
at com.xxx.proj.config.DatabaseConfiguration.mongobee(DatabaseConfiguration.java:62)
at com.xxx.proj.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$4ae465a5.CGLIB$mongobee$1(<generated>)
at com.xxx.proj.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$4ae465a5$$FastClassBySpringCGLIB$$f202afb.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.xxx.proj.config.DatabaseConfiguration$$EnhancerBySpringCGLIB$$4ae465a5.mongobee(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 22 common frames omittedjhipster 5必须使用不同的版本,因为我在实现上面的代码时得到了它。看来它期待的是一个不同的版本。
https://stackoverflow.com/questions/49974594
复制相似问题