[英]Resources loaded from target/test-classes on first run after build
Whenever I do a maven clean install on my project and then run the application from IntelliJ IDEA, the resources are wrongly loaded from target/test-classes instead of target/classes. 每当我在项目上执行maven全新安装,然后从IntelliJ IDEA运行应用程序时,就会从目标/测试类而不是目标/类中错误地加载资源。 This only happens on first run, after I stop and restart the application, the files are loaded correctly from target/classes everytime, until I do a new maven clean install.
这仅在第一次运行时发生,在我停止并重新启动应用程序之后,每次都会从目标/类正确加载文件,直到执行新的maven全新安装为止。
What could cause this behavior? 是什么导致这种现象? Isn't target/test-classes only supposed to be used during test phase?
目标/测试类别不是仅应在测试阶段使用吗?
EDIT 1: Add snippet of resources build from pom 编辑1:添加从pom构建的资源片段
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Add <testresources>
to the <build>
node of the maven POM, like this: 将
<testresources>
添加到Maven POM的<build>
节点,如下所示:
<testResources>
<testResource>
<directory>${project.basedir}/src/test/java</directory>
</testResource>
</testResources>
在今天为IntelliJ安装了新的2017更新之后,该问题消失了,并且在第一次运行时从正确的文件夹中加载了资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.