Unable to find org.springframework.format.datetime.standard.DateTimeConverters

守給你的承諾、 提交于 2019-12-10 23:45:47

问题


There is a Spring class, org.springframework.format.datetime.standard.DateTimeConverters, with some useful converters, that I am not able to find. It is documented in the 4.1.0.RC1_to_4.1.0.RC2 javadoc but not in the 4.1.0.RELEASE. Note the @UsesJava8 annotation in the javadoc. Of course I am using Java 8 as I need to convert between the new types.

The class has its source code in GitHub with the 4.1 tag and I add the project by Maven using the following xml to my pom.xml.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.2.1.RELEASE</version>
</dependency>

Were the converters moved to another package? Where can I find them?


回答1:


The spring-context artifact in version 4.2.1 contains the DateTimeConverters class, as can be seen in the GitHub repo.

Note however that it is a package class, it is not part of the public API and that's why this class is not visible in the online Javadoc. javadoc, by default, does not generate HTML pages for package classes; quoting its reference (emphasis mine):

The javadoc command parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields.

And if you're really curious, you can see that Spring keeps the default values during Javadoc generation, by looking at their build.gradle.

If you're using Java 8, Spring automatically registers those converters with the following XML declaration:

<mvc:annotation-driven conversion-service="conversionService"/>

<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />


来源:https://stackoverflow.com/questions/32507470/unable-to-find-org-springframework-format-datetime-standard-datetimeconverters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!