[英]Use jar file resource while running from intellij idea IDE
I have a java project that uses a resource file that is put into the jar file. 我有一个Java项目,该项目使用放入jar文件中的资源文件。 All runs well while starting it with java -jar app.jar.
使用java -jar app.jar启动它时,所有程序运行良好。 But running it from a IDE, it doesn't find the file.
但是从IDE运行它时,找不到文件。
Is it possible to run and debug the project from the IDE? 是否可以从IDE运行和调试项目?
Just in case anyone is still looking I solved this by creating the jar as an artefact. 以防万一有人还在寻找,我通过将罐子制成人工制品解决了这个问题。
To get the resources I use -jar path/to/my.jar in VM options in Edit configurations in the Run menu. 为了获得资源,我在“运行”菜单的“编辑配置”中的VM选项中使用-jar path / to / my.jar。
Goto "open module setting" by right clicking the project. 通过右键单击项目转到“打开模块设置”。 add the jar as a library in project setting.
在项目设置中将jar添加为库。 go to dependency tab of the module and add that.
转到模块的依赖项标签并添加。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.