草庐IT

file_time_type

全部标签

Java 错误 : "incompatible types" message

我在编译期间遇到Java错误:UserID.java:36:error:incompatibletypes+generator.nextInt(10);^required:Stringfound:intJava代码如下:publicclassUserID{privateStringfirstName;privateStringuserId;privateStringpassword;publicUserID(Stringfirst){Randomgenerator=newRandom();userId=first.substring(0,3)++generator.nextInt(1)

Java 泛型和注解 : Type-Safe

我知道我可以做类似的事情:publicclassAbstractDao{}在这种情况下,Bean是一个类或接口(interface)。我想知道是否有办法用注释来做到这一点,比如:publicclassAbstractDao{}这样的事情可能吗?提前致谢! 最佳答案 不幸的是,注解中没有继承,所以这是不可能的。在这里查看类似问题的答案:WhyisnotpossibletoextendannotationsinJava? 关于Java泛型和注解:Type-Safe,我们在StackOverf

java - Ant Java 任务 : how to get output to console and a file-always record build output without shell redirection

我正在使用ant启动Java程序。我不想在程序终止后“松散”输出。所以我使用属性“output”将输出存储在文件中。不幸的是,我没有任何控制台输出了。在控制台和txt文件中输出的好方法是什么。我正在寻找替代品antmytast>myFile.txt因为我不想,“用户”必须使用shell重定向“>..”。.如果他/她不选择重定向,则输出将丢失。 最佳答案 Ant有一种记录输出的方法。http://ant.apache.org/manual/Tasks/recorder.html.Arecorderisalistenertothecur

java - 组织.hibernate.MappingException : No Dialect mapping for JDBC type: 1111

InitialSessionFactorycreationfailed.org.hibernate.MappingException:NoDialectmappingforJDBCtype:111127Dec,20126:38:34PMorg.apache.catalina.core.StandardWrapperValveinvokeSEVERE:Servlet.service()forservletcommissionthrewexceptionorg.hibernate.MappingException:NoDialectmappingforJDBCtype:1111atorg.

java - 如何将 java.time.Duration 映射到 XML

我有一个数据类型为:privatejava.time.Durationduration类属性是这样设置的:object.setDuration(Duration.ofSeconds(2));我想将我的对象编码为xml,以便持续时间看起来像那样PT2S定义ISO8601据我了解,Jaxb使用defaultbindingdatatypes喜欢:xsd:durationjavax.xml.datatype.Duration但在我的bean中我不想包含任何xml依赖项。我看到了编写包装器的可能性,我可以在其中添加XmlAdapter,但我不知道如何将java.time.Duration转换为j

java - 在 JSTL <fmt :formatDate> action 中使用 java.time.LocalDate

我还没弄清楚如何显示java.time.LocalDateJSP中的值。在我的JSP中,我有这个:std.datum类型为java.time.LocalDate.呈现JSP时出现此异常:javax.el.ELException:Cannotconvert2015-02-14oftypeclassjava.time.LocalDatetoclassjava.util.Date我假设这是转换?那么是否可以用格式化LocalDate类的实例?行动? 最佳答案 I'massumingit'stheconversion?是的,这是一个与转换相

dd-MMM-yyyy 格式的 java.time.format.DateTimeParseException

这个问题在这里已经有了答案:Howtoparsecase-insensitivestringswithJSR-310DateTimeFormatter?(3个答案)关闭6年前。我正在尝试解析dd-MMM-yyyy格式的日期。packagecom.company;importjavax.swing.text.DateFormatter;importjava.time.format.DateTimeFormatter;importjava.time.*;importjava.util.Locale;publicclassMain{publicstaticvoidmain(String[]a

java - 最糟糕的警告 : Slave exited abnormally due to TIMED_OUT

我应该如何摆脱这个警告并为pitest添加超时常量?我的命令是:mvnjacoco:reportorg.pitest:pitest-maven:mutationCoveragesonar:sonar-Dpitest.timeoutConst=8000但它抛出:警告:由于TIMED_OUT从站异常退出 最佳答案 您不太可能摆脱所有警告-它们是在突变创建无限循环时生成的。Pitest通过将每个测试的执行时间与不存在突变时所花费的时间进行比较来检测这些。如果测试需要更多的时间来运行,那么该进程将被终止并将突变标记为超时。pitest报告警

java - 为什么 File 中的某些方法使用 boolean 值来指示其成功(而不是仅仅抛出异常)有什么原因吗?

Java中的File类包含使用boolean值指示操作是否成功的方法。要求使用上述方法的用户在每次调用时检查返回值。以下是从mkdir()中获取的说明要求的文档片段:publicbooleanmkdir()Createsthedirectorynamedbythisfile,assumingitsparentsexist.Usemkdirsifyoualsowanttocreatemissingparents.NotethatthismethoddoesnotthrowIOExceptiononfailure.Callersmustcheckthereturnvalue.createN

java - 编译时间 : no instance(s) of type variable(s) U exist

以下语句虽然毫无意义,但在句法上是合理的。finalStreamfoobar=IntStream.empty().flatMap(x->IntStream.empty().mapToObj(y->IntStream.empty().mapToLong(z->1)));//compilationerrorhereon`z->1`但是它不编译,返回:java:incompatibletypes:badreturntypeinlambdaexpressionnoinstance(s)oftypevariable(s)Uexistsothatjava.util.stream.Streamcon