草庐IT

mongo-express

全部标签

java - 切换枚举值 : case expressions must be constant expressions

我有一个具有以下结构的枚举:publicenumFriends{Peter("PetervonReus","Engineer"),Ian("IandeVilliers","Developer"),Sarah("SarahRoos","Sandwich-maker");privateStringfullName;privateStringoccupation;privatePerson(StringfullName,Stringoccupation){this.fullName=fullName;this.occupation=occupation;}publicStringgetFul

java - spring-data mongo 中不区分大小写的精确匹配

我正在使用带有mongo的spring数据和一个存储库。例如:@Query("{'userName':?0}")publicUserfindByUsername(Stringusername);我想让这个不区分大小写。我使用了以下查询:"{'userName':{$regex:?0,$options:'i'}}"这行得通,但它不仅匹配testUser,还匹配estUser。我也试过"{'userName':{$regex:^?0$,$options:'i'}}"但这无法解析查询,因为它试图在正则表达式中插入引号。com.mongodb.util.JSONParseException:(

java - 使用 Spring 定义 Mongo 模式验证

我想使用Spring-boot和JSONSchemavalidator选项在Mongo中定义一个集合(https://docs.mongodb.com/manual/core/schema-validation/#json-schema),我不想要JSR-303Bean验证(这不是有效答案SpringdatamongoDbnotnullannotationlikeSpringdataJpa),但在创建集合时定义一个选项,该选项使用CollectionInfos()显示在JSON中。例如,如果我定义一个Account模型类,例如:publicclassAccount{@Idprivate

java - Spring boot 2.0.5.RELEASE 和 mongo 4.0 连接问题

我正在关注Springwebsite上的使用MongoDB访问数据教程我安装了MongoDB服务器版本4作为服务当我使用客户端连接到它时,它的身份验证工作正常。我面临以下问题:MongoCommandException:Commandfailedwitherror18:'Authenticationfailed'我看到代码使用的是与服务器版本4不兼容的mongodb-driver-core-3.6.4.jar如何在不打乱项目的情况下只升级驱动?为什么他们使用spring-boot-starter-data-mongodb而不是mongodb-driver-sync?com.mongod

java - getClass() 文档中的 "the erasure of the static type of the expression on which it is called"是什么意思?

"publicfinalClassgetClass()"的文档对象的方法说:TheactualresulttypeisClasswhere|X|istheerasureofthestatictypeoftheexpressiononwhichgetClassiscalled.Forexample,nocastisrequiredinthiscodefragment:我不明白这个解释,特别是关于什么|X|据说是-“删除调用getClass的表达式的静态类型”。|X|是什么形式的符号?或者,也许,还有什么地方会|X|使用类型符号? 最佳答案

java - EL1008E :(pos 8):Property or field cannot be found on object of type '...security.web.access.expression.WebSecurityExpressionRoot' maybe not public?

我正在使用SpringMVC(版本4.3.1.RELEASE)开发Spring-Security-Access-Control-Example+SpringSecurity(4.1.1.RELEASE)。只是想在Web应用程序上实现访问控制或授权。当我简单地启动URL时:http://localhost:8080/Spring-Security-Access-Control-Example/admin.我收到以下错误,我真的精疲力尽地解决了这个问题。错误信息/堆栈:java.lang.IllegalArgumentException:Failedtoevaluateexpression

java - 处理警告 : "The expression of type x is boxed into x" 的正确方法是什么

我不想要关闭或忽略TheexpressionoftypexisboxedintoX?中的警告.如果有人愿意的话,我想知道处理/避免此警告的正确方法是什么。 最佳答案 装箱和拆箱是您可以手动完成的操作,但它们内置于语言中以避免您无疑会遇到的重复。Integerobj=Integer.valueOf(5);//insteadofIntegerobj=5;inti=obj.intValue();//insteadofinti=obj;在我看来,处理该警告的适当方法是将其关闭。但如果这不是一个选项,您可以执行上述操作。

java - 类型安全 : The expression of type List needs unchecked conversion to conform to List<Object[]>

当我想启动一个Hibernate应用程序时,我总是收到类型安全警告。有没有一种方法可以在不使用@SuppressWarnings("unchecked")的情况下摆脱这种情况?这是我的代码:Configurationconfig=newConfiguration();config.addAnnotatedClass(Employee.class);config.configure("hibernate.cfg.xml");newSchemaExport(config).create(false,false);ServiceRegistryserviceRegistry=newStand

php - Expression Engine CMS 如何动态填充元标记?

我正在尝试将描述和关键字的元标记添加到我的表达式引擎网站。我的结构是这样的:我有一个在每个模板中调用的{top}片段在head标签里面我有这个{ifsegment_1==""}EpicSoftwareGroup,Inc.{if:else}{exp:channel:entrieschannel="main|blog|projects"limit="1"disable="categories|category_fields|custom_fields|member_data|pagination"}EpicSoftwareGroup,Inc.-{title}{/exp:channel:en

node.js - 如何使用 express for Google 重定向不同的语言

我正在使用两种语言运行网络应用程序。这工作正常,但谷歌没有索引我的语言目录。Google只显示domain.com而不是domain.com/en/或domain.com/de/。我正在使用expressjs处理301重定向,但我不确定为什么Google没有将其编入索引。app.get('/',function(req,res){constlanguage=req.acceptsLanguages()[0].slice(0,2).toLowerCase();if(language==='de'){res.redirect(301,'/de/');}elseif(language==='