草庐IT

a_very_long_method_name

全部标签

Java EE 异常 : Name java:comp is not bound in this Context

我在Netbeans7.2.1中安装了JavaEE应用程序。尝试部署它(构建结束正常),我在Tomcat日志中收到错误:Causedby:javax.naming.NameNotFoundException:Namejava:compisnotboundinthisContextatorg.apache.naming.NamingContext.lookup(NamingContext.java:770)atorg.apache.naming.NamingContext.lookup(NamingContext.java:153)atjavax.naming.InitialContex

java - 断言失败错误 : null on boolean method

我正在测试一个将两个对象作为参数并返回boolean的方法.当我使用和assertTrue或assertFalse在有问题的方法上,我得到以下测试失败:junit.framework.AssertionFailedError:null.我知道我正在传递无效参数并且可能会导致NPE在方法中,但这不是正在发生的事情,而是测试失败了。注意:我正在使用boolean而不是Boolean.示例代码:类:publicclassMyClass{publicbooleanfoo(MyObject1lhs,MyObject2rhs){//doSomething//returnsomething}}测试:

java - 对 long 和 double 的大小感到困惑

这个问题在这里已经有了答案:Whatisthedifferencebetweenthefloatandintegerdatatypewhenthesizeisthesame?(3个答案)关闭3年前。看看Java(但在其他语言中可能相似或相同),long和double都使用8个字节来存储一个值。一个long用8个字节存储从-9,223,372,036,854,775,808到9,223,372,036,854,775,807的长整数double使用8个字节来存储从-1.7E308到1.7E308的doublefloat,最多16位有效数字。我的问题是,如果两者都使用相同的字节数(8个字节

Java 泛型 : method signature for (deep copy of) generic Maps

我有一些Map,它们本身又可能包含Map(任何类型)。我写了一个带有签名的方法:publicstaticHashMapdeepCopyHashMap(HashMaps);但是,我现在想概括此代码以支持一般的Map,但仍会返回与参数类型相同的对象。所以不是:publicstaticHashMapdeepCopyHashMap(HashMaps);publicstaticCheckedMapdeepCopyCheckedMap(CheckedMaps);publicstaticTreeMapdeepCopyTreeMap(TreeMaps);...etc.我想要这样的东西:publicst

java - 错误 : Attempted to call method "format" on null context object

Spring-bootv1.4.1Javav1.8Thymeleafv2.1.5。下面这行代码在我看来:它具有我基于S.O.的语法。问题SpringBootThymeleafOrdinalNumbers,产生错误:org.springframework.expression.spel.SpelEvaluationException:EL1011E:(pos11):Methodcall:Attemptedtocallmethodformat(java.time.LocalDate,java.lang.String)onnullcontextobject但是,如果我在没有Thymeleaf

java - 将对象列表转换为 Long 列表

我有一个类如下:Class1{privateClass2class2;...}我想将Class1列表转换为Class2::getId()列表,这是我尝试过的:Listclass2List=class1List.stream().map(Class1::getClass2).collect(Collectors.toList());Listclass2Ids=class2List.stream().map(Class2::getId).collect(Collectors.toList());有没有办法在一条指令中做到这一点? 最佳答案

java - Play Framework : Redirect to controller method with arguments

我正在使用PLAY框架2.2.1构建一个Web应用程序,并试图在地址栏中显示所请求站点的所有可用httpget查询参数,即使是那些未在请求中设置的参数。在这种情况下并非所有httpget参数都已设置,我想添加具有默认值的未设置参数并进行重定向。我有一个可以使用GET请求的站点:GET/testcontrollers.Application.test(q:String,w:String?=null,f:String?=null,o:String?=null)这是我希望在controllers.Application中使用的方法:publicstaticResulttest(Stringq

java - 找不到 JSF 2.1.13 自定义组件 : Tag Library supports namespace: <namsepace> but no tag was defined for name: <compositecomponent>

问题我正在使用JSF2.1.13创建一个原型(prototype),以展示JSF相对于我们当前使用JSP和struts1.1构建的webapp的优势>。我遵循使用JSF2.2.6的代码,但是一旦发现OracleWeblogic12c尚不支持JSF2.2,我不得不降级。使用2.1.13运行代码时,我收到以下错误:/pages/sites/tab-details.xhtml@27,90TagLibrarysupportsnamespace:http://java.sun.com/jsf/composite/ccc,butnotagwasdefinedforname:codedType谷歌搜

Java8 : Is there a way to get an instance method reference from a class method reference?

例如,如果我有这样的界面:publicinterfaceFooBar{Bfoo(Aa);Bbar(Aa);}有没有办法像FooBar::bar那样获取类级别的方法引用?并获取实例方法引用?即。如果我有FooBarmyFooBarInstance;BiFunction,A,B>barFunction=FooBar::bar;有什么简单的方法可以得到Function与我定义的实例相匹配的实例FunctionmyBarFunction=myFooBarInstance::bar; 最佳答案 您想要做的在函数编程世界中被称为“部分函数应用程

Java Apache Spark : Long transformation chains result in quadratic time

我有一个使用ApacheSpark的Java程序。该程序最有趣的部分如下所示:longseed=System.nanoTime();JavaRDDannotated=documents.mapPartitionsWithIndex(newInitialAnnotater(seed),true);annotated.cache();for(intiter=0;itera.sum(b));//updateoverallcounts(*)seed=System.nanoTime();//copyoverallcountswhichCountChangerusestocomputeastoch