简体   繁体   English

用于Play框架中的mime检测的Java Service Provider接口?

[英]Java Service Provider Interface for mime-detection in Play Framework?

The Java 7 implementation of probeContentType(path) is pretty incomplete so wanted to use Apache Tika for better reliability. probeContentType(path)的Java 7实现非常不完整,因此希望使用Apache Tika以获得更好的可靠性。 I found a post about how to override the probeContentType function via using the Java SPI in Maven but am not sure how to accomplish the same thing in the Play! 我找到了一篇有关如何通过在Maven中使用Java SPI 覆盖probeContentType函数的帖子,但不确定如何在Play中完成相同的操作! Framework which uses sbt? 使用sbt的框架?

Per the link you provided, all you need is to insure that: 根据您提供的链接,您需要确保:

  1. The file src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector exists 文件src / main / resources / META-INF / services / java.nio.file.spi.FileTypeDetector存在
  2. Its contents are the fully qualified class name of your FileTypeDetector wrapper around Tika 它的内容是Tika周围FileTypeDetector包装器的完全限定的类名。
  3. The file gets copied into the META-INF/services directory in the JAR file when it is built. 构建文件后,该文件将被复制到JAR文件的META-INF / services目录中。

Exactly how you perform the last step will depend on how exactly you are building the jarfile. 究竟如何执行最后一步将取决于您构建jarfile的精确程度。 One possible starting point is https://stackoverflow.com/a/9772931/390153 . 一个可能的起点是https://stackoverflow.com/a/9772931/390153

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM