草庐IT

public_method

全部标签

java - MongoDB Java 驱动程序 3.x : How to pass allowDiskUse=true to aggregate() method?

我正在使用mongo-java-driver3.0.2。我有一个使用MongoCollection.aggregate(Listpipeline)的方法排序和限制:privatestaticMongoIterableselectTop(intn){BasicDBObjectsortFields=newBasicDBObject("score",-1);BasicDBObjectsort=newBasicDBObject("$sort",sortFields);BasicDBObjectlimit=newBasicDBObject("$limit",n);Listpipeline=new

java - eclipse : list methods and variables of all classes

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭5年前。Improvethisquestion我开始使用一些由其他人编写的Java代码。我必须理解、改变和测试它。作者现在不在。该包有大约50个不同大小的文件(以及类)。如果我可以看到/打印出方法的名称(公共(public)和私有(private))和公共(public)变量(就像它们在Eclipse的“大纲窗口”中可见一样),那就太好了。这对理解代码非常有帮助,因为我可以只看它并理解每个类的一般用途。除了生成J

java - 公共(public)日志配置 : use SimpleLog & set debug level

我有一个公共(public)日志配置问题。我希望它使用SimpleLog(而不是java.util.logging)并记录级别>=debug(而不是信息)的所有消息。 最佳答案 根据commons-loggingdocs,您应该能够通过将commons-logging.properties文件放置在类路径的根目录中,使用以下条目显式配置它以使用SimpleLog:org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog然后您可以configure

java - 该方法只能设置 public/protected/private 之一

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭上个月。Improvethisquestion我正在实现一个接口(interface):publicinterfaceConsultant{//somedocumentationhereexplainingitshouldthrow3typesofexceptionsCellLocationsuggest(GameBoardgameBoard)

java - Jackson JSON - 解码时出现 "no single-String constructor/factory method"错误

最简单的情况给我带来了麻烦。我第一次遇到它。我能够解码稍微复杂的json,但这个简单的失败了。什么会导致这种情况?为什么jackson只用一个字符串就有问题?保存用户角色名称的简单类。publicclassUpdateUserRole{privateStringname;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}}Controller内部publicvoidupdateUserRole(@PathVariableLongid,@RequestBodyUpdateUser

java - Jersey REST WS 错误 : "Missing dependency for method... at parameter at index X"

我收到以下错误:Apr09,201312:24:26PMcom.sun.jersey.spi.inject.ErrorsprocessErrorMessagesSEVERE:Thefollowingerrorsandwarningshavebeendetectedwithresourceand/orproviderclasses:SEVERE:Missingdependencyformethodpublicjavax.ws.rs.core.Responsecom.package.ImportService.specifyLocalFile(java.lang.String,java.l

java - Tomcat 6 : how to delete temporary files after a web method call has ended?

我有一个临时文件,其中包含通过MTOM二进制附件作为SOAP响应的一部分返回的数据。我想在方法调用“结束”(即完成传输)后立即将其丢弃。对我来说最好的方法是什么?我能弄清楚如何执行此操作的最佳方法是在session被销毁时删除它们,但我不确定是否有更“直接”的方法来执行此操作。仅供引用,我没有使用Axis,我使用的是jax-ws,如果这很重要的话。更新:我不确定回答者是否真的理解这个问题。我知道如何在java中删除文件。我的问题是:@javax.jws.WebServicepublicclassMyWebService{...@javax.jws.WebMethodpublicMyFi

java - Scala:类中的公共(public)静态最终

我正在尝试在Scala中为Java的publicstaticfinal获得一个真正的等价物,以使用TwiP.在object中创建val对我不起作用,因为它是新生成的类Example$.class的一部分,并且TwiP无法从类Example.class访问它。这是我尝试移植到Scala的Java类的示例:publicstaticfinalString[]MY_STRINGS={"A","B","C"};@TestpublicvoidmyTest(@Values("MY_STRINGS")Stringstring){...}但我不知道如何将publicstaticfinal移植到Scala

java - 重载 Math.sqrt : overloading method seems to hide the original one

尝试为int类型重载java.lang.Math.sqrt静态方法:importstaticjava.lang.Math.sqrt;classTest{privatestaticdoublesqrt(intn){returnsqrt(1.0*n);}publicstaticvoidmain(String[]args){System.out.println(sqrt(1));}}出现一个奇怪的错误:Test.java:7:sqrt(int)inTestcannotbeappliedto(double)returnsqrt(1.0*n);^1error但是当显式引用java.lang.Ma

Java 反射 : How to get methods with no parameters only

我正在做一项关于Java反射的学校作业。详情如下:Writeaconsoleprogramthataskstheuserforaclassname,loadsthatclassandcreatesaninstanceofit.Weassumethattheclasshasaconstructorwithoutanyparameters.Then,theprogramprintsoutthenamesandvaluesofthepublicvariablesofthecreatedobject,andalsoalistofthepublicmethodsthatdonotspecifya