编译java项目,build actifacts为jar后,运行jar报错:
Error: Invalid or corrupt jarfile
解决办法:
Make sure your MANIFEST.MF is in:
src/main/resources/META_INF/NOT
src/main/java/META_INF/
需要将mainfest路径设置为resources下,默认在java下
问题分析:
IDEA中,在File\Project Structure\Artifacts\添加artifacts的时候,默认会在src/main/java/META_INF/下创建目录,但是此目录(src/main/java/)已标记为Sources Root,仅编译;
所以应该将src/main/java/META_INF剪切到src/main/resources/META_INF/,src/main/resources/是Resources Root,会拷贝到out目录
参考:https://www.cnblogs.com/zjoch/p/7646042.html