在构建期间复制到Java资源目录时,Maven损坏了WAV文件 [英] Maven corrupts WAV file when copying to Java resource dir during build

查看:208
本文介绍了在构建期间复制到Java资源目录时,Maven损坏了WAV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的Maven Java项目,需要播放WAV文件,因此为了简化起见,我宁愿将文件简单地放入src/main/resources/*文件夹中.但是,如果使用

I've got a small Maven Java project which requires the playing of a WAV file, and so I'd prefer to simply put the file into the src/main/resources/* folder for simplicity. However, if the same WAV file which works fine being loaded from disk using AudioSystem.getAudioInputStream(...) is then put in the Maven resources directory, the program throws an instance of RIFFInvalidDataException:

com.sun.media.sound.RIFFInvalidDataException: Chunk size too big
    at com.sun.media.sound.RIFFReader.<init>(RIFFReader.java:82)
at com.sun.media.sound.WaveFloatFileReader.internal_getAudioFileFormat(WaveFloatFileReader.java:65)
    at com.sun.media.sound.WaveFloatFileReader.getAudioFileFormat(WaveFloatFileReader.java:55)
    at com.sun.media.sound.WaveFloatFileReader.getAudioInputStream(WaveFloatFileReader.java:117)
    at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1113)
    at se.kth.speech.coin.tangrams.TangramsClient.playSound(TangramsClient.java:276)
    at se.kth.speech.coin.tangrams.TangramsClient.signalGameStart(TangramsClient.java:335)
    ... 17 more

此外,如果我使用 VLC 尝试在$PROJECT/target/classes/org/coolproject/audio/,该程序实际上崩溃了;原始文件的处理没有任何问题

Moreover, if I use VLC to try to open the WAV file at $PROJECT/target/classes/org/coolproject/audio/, the program actually crashes; The original file is handled without any problems

Maven在处理我的音频文件是什么?我使用的是嵌入在Eclipse Neon.3 v4.6.3(内部版本20170314-1500)中的版本3.3.9/1.7.0.20160603-1931,不幸的是,由于构建依赖于Eclipse,因此无法尝试使用适当的" Maven实例来构建项目. 一个古老的Eclipse项目(包括Java源代码和预编译的DLLs和一个仅Java的Maven项目)的噩梦混合../p>

What on Earth is Maven doing with my audio file(s)? I'm using version 3.3.9/1.7.0.20160603-1931 embedded in Eclipse Neon.3 v4.6.3 (build 20170314-1500) and unfortunately cannot try building the project with a "proper" Maven instance outside of Eclipse because building depends on a nightmare hybrid of an old Eclipse project including both Java source and pre-compiled DLLs and a Java-only Maven project.

推荐答案

您可能已经进行了具有副作用的过滤.根据资源插件的文档,您可以像这样禁用过滤:

You probably have filtering that has side-effects. As per the resources plugin's docs, you can disable filtering like this:

<project>
...
<build>
    ...
    <resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
    </resource>
    ...
    </resources>
    ...
</build>
...
</project>

要查看文档,请在此处

这篇关于在构建期间复制到Java资源目录时,Maven损坏了WAV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆