this Stack Overflow question에 제안 된 솔루션을 내 Maven 프로젝트에 추가했습니다. 내가 제안한 제안 된 솔루션의 유일한 차이점은 <tasks />
을 <target />
으로 대체하는 것입니다 (발생한 문제는이 중 하나와 함께 나타남).maven-antrun-plugin이 실행을 건너 뜁니다.
모든 것이 테스트면에서 뛰어납니다. 테스트를 실행할 때 올바른 (test-persistence.xml) 지속성 파일이 사용되고 있습니다. 그러나 내가 깔끔한 설치를하거나 내 IDE (Netbeans 8.2)에서 실행을하면 첫 번째 대상 (copy-test-persistence) 만 실행됩니다. 두 번째 실행은 테스트 후에 입력되지만 (아래 빌드 출력 참조) 대상은 실행되지 않습니다. 모든 clean install
이후에 내가 무엇을하는지, 그리고 서버에서 앱을 실행할 때 test-persistence.xml
의 내용이 persistence.xml
파일에 있다는 것입니다. 올바른 콘텐츠는 첫 번째 대상에 생성 된 persistence.xml.proper
에 남아 있습니다.
--- maven-antrun-plugin:1.8:run (copy-test-persistence) @ RimmaNew ---
Executing tasks
main:
[copy] Copying 1 file to /my-project-home/target/classes/META-INF
[copy] Copying 1 file to /my-project-home/target/classes/META-INF
Executed tasks
...
--- maven-antrun-plugin:1.8:run (restore-persistence) @ RimmaNew ---
Executing tasks
main:
Executed tasks
restore-persistence
에는 0 개의 작업이 실행됩니다. 당신이 나에게 나는이 주위에 내 머리를 얻을 수있는 힌트를 줄 수 있다면 그것은 감사하겠습니다
<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="main" >
<target name="main">
<copy file="/home/vgorcinschi/NetBeansProjects/rimmanew/target/classes/META-INF/persistence.xml.proper" tofile="/home/vgorcinschi/NetBeansProjects/rimmanew/target/classes/META-INF/persistence.xml"/>
</target>
</project>
: 생성 된 /target/antrun
폴더에 이상하게도 건너 뛴 작업을 포함하는 build-main.xml
파일이있다. 내가 게시하고 공통으로 내 현재 pom.xml
:
copy
작업 작업 방법과 함께 할 수있어 한
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>copy-test-persistence</id>
<phase>process-test-resources</phase>
<configuration>
<target>
<!--backup the "proper" persistence.xml-->
<copy file="${project.build.outputDirectory}/META-INF/persistence.xml" tofile="${project.build.outputDirectory}/META-INF/persistence.xml.proper" />
<!--replace the "proper" persistence.xml with the "test" version-->
<copy file="${project.build.testOutputDirectory}/META-INF/test-persistence.xml" tofile="${project.build.outputDirectory}/META-INF/persistence.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>restore-persistence</id>
<phase>prepare-package</phase>
<configuration>
<target>
<!--restore the "proper" persistence.xml-->
<copy file="${project.build.outputDirectory}/META-INF/persistence.xml.proper" tofile="${project.build.outputDirectory}/META-INF/persistence.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
화려한 - 내 문제가 해결되었습니다. 고마워요! – vasigorc