我发现浏览器正在连接到@Bean("primary")
public SimpleMongoRepository<ProductModel, String> getPrimaryProductRepository() {
TypeInformation<ProductModel> typeInformation = ClassTypeInformation.from(ProductModel.class);
BasicMongoPersistentEntity<ProductModel> mongoPersistentEntity = new BasicMongoPersistentEntity<ProductModel>(typeInformation);
//add Id-property, o/w SimpleMongoRepository asks (e.g. delete()) getIdQuery(id) and we fail on `entityInformation.getIdAttribute()`
Class<ProductModel> aClass = ProductModel.class;
Field field = null;
try
{
field = aClass.getDeclaredField("id");
}
catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Property property = Property.of(ClassTypeInformation.from(ProductModel.class), field);
MongoPersistentProperty idProperty = new BasicMongoPersistentProperty(property , mongoPersistentEntity, SimpleTypeHolder.DEFAULT, null);
mongoPersistentEntity.addPersistentProperty(idProperty);
MongoEntityInformation<ProductModel, String> mongoEntityInformation = new MappingMongoEntityInformation<ProductModel, String>(mongoPersistentEntity);
return new SimpleMongoRepository<>(mongoEntityInformation, primaryMongoTemplate());
}
。
我尝试使用https://www.npmjs.com/package/websocket上的简单客户端示例在此Websocket上进行侦听,但是尽管我的应用程序进行了更改并且浏览器进行了实时更新,但没有记录任何消息。
客户代码供参考:
ws://localhost:7687/