草庐IT

start_focus_time

全部标签

Java 接口(interface) Start/Stop 已经存在?

与这个合约有接口(interface)start();stop();已经存在?我有印象要在这里重新编码一些经典的东西...... 最佳答案 org.springframework.context.Lifecycle 关于Java接口(interface)Start/Stop已经存在?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/16650073/

java - 如何使用@timed 注释监视服务bean?

Jhipster开发团队建议对要监控的服务使用@Timed注解。它显示在创建服务页面(http://jhipster.github.io/creating_a_service.html)。那么它在JHipster中是如何工作的呢?我如何监视这些注释的服务?在所有服务中维护这个注释的成本是多少?在生产中使用此注释会产生任何处理开销吗? 最佳答案 JHipster使用DropWizardMetrics(你看过技术堆栈here了吗?),那些@Timed注释来自SpringsupportforDropwizardMetrics.要了解有关D

java - Connection.isValid(time) 实际上做了什么来检查连接是否有效?

使用OJDBC进程是否使用isValid方法检查连接是否仍然存在?我试图弄清楚它可能对数据库产生什么影响以及这个过程有多繁重。例如它是请求一个列,还是只用几个字节的数据对数据库执行ping操作。 最佳答案 每个供应商以不同的方式实现jdbc方法。例如Oracle的实现是:publicbooleanisValid(intvar1)throwsSQLException{returnthis.pingDatabase(var1)==0;}pingDatabase简单地执行selectxfromdual:intdoPingDatabase(

java - 如何用模式格式化 java.time.LocalDateTime 和 java.time.LocalDate?

在下面的片段中,属性$F属于java.time.LocalDateTime或java.time.LocalDate类。如何在jasper报告中使用textFieldpattern格式化此属性? 最佳答案 要在当前版本的jasper-report中为日期/时间对象使用模式属性,您需要java.util.Date类或其子类之一。解决方法是将java.time.LocalDate和java.time.LocalDateTime进行转换转换为java.util.Datefromjava.time.LocalDatefromjava.time

java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME 无法解析时区名称

我正在尝试从定义为使用RFC1123兼容日期时间规范的数据源解析时间戳。我的代码是:value=Instant.from(DateTimeFormatter.RFC_1123_DATE_TIME.parse(textValue));这对某些数据工作正常,但我得到包含区域名称的字符串的异常,即使是在RFC2822中定义的字符串(它从RFC1123间接引用,因为它废弃了RFC822)。示例:java.time.format.DateTimeParseException:Text'Sun,20Aug201700:30:00UT'couldnotbeparsedatindex26java.ti

java - 在 App 层之间传递 Joda Time 对象

我正在考虑使用Joda-Time.我想知道我是否应该注意我的接口(interface)返回的对象类型。从服务层上的接口(interface)签名返回Joda-Time对象意味着使用它的每个模块都将依赖于Joda-Time而不是常见的java.util.Date。API.您是在应用模块周围传递Joda对象,还是在应用的特定部分编写包装器? 最佳答案 一开始,只返回最合适的类型(在本例中为Joda对象)。如果您了解到有人对此有疑问(这种情况可能不会经常发生),要么向接口(interface)添加转换器方法(例如,getTime()和现在

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?是的,这是一个与转换相

java - list .MF : difference between Main-Class and Start-Class

在我接手的一个项目中,发现了一个Jar文件,里面有如下MANIFEST.MF文件:Manifest-Version:1.0Start-Class:com.xxx.ApplicationSpring-Boot-Version:1.2.7.RELEASEMain-Class:org.springframework.boot.loader.JarLauncherStart-Class和Main-Class有什么区别? 最佳答案 这是SpringBoot的一个特性。Main-Class定义SpringBoot的org.springframe

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