所以我尝试了不同的东西,在编译项目时将我想要的necesarry .exe文件复制到目标文件夹中。我还查看了Move a text file into target folder when compiling a Maven project的Q&A - 但它没有帮助。
所以我想要的是在编译项目时使用mvn clean install
将'chromedriver.exe'复制到目标文件夹。我需要这个.exe来启动我的jar文件。
任何帮助表示赞赏!
如果您使用的是默认配置,则放置在src / main / resources中的任何文件都将自动包含在生成的build(目标)文件夹中。但是,您应该只包含应该在生成的jar中的文件。
我找到了一个自己的解决方案:在pom.xml中,包括
<resources>
<resource>
<directory>${project.basedir}</directory>
<targetPath>${project.build.directory}</targetPath>
<includes>
<include>chromedriver.exe</include>
</includes>
</resource>
</resources>
在build
标签下。