2017-03-10 6 views
0

리소스를 별도의 실행 태그로 필터링 할 수 있습니까? 제 목표는 서로 다른 필터 파일을 사용하여 리소스를 필터링하여 2 개의 war 파일을 만드는 것입니다. 실제로이 솔루션은 작동하지 않습니다. 변수에는 값이 없습니다. 그대로 있습니다. <jta-data-source>${ds-jta}</jta-data-source> - 나는 필터 및 리소스 태그를 메이븐 - 전쟁 - 플러그인 - 주석 섹션 외부에 추가해야합니다. 스 니펫에 나와있는 것처럼 실행 구성에서이 "필터링"을 지정할 수 있다고 생각했습니다.Maven war 플러그인을 별도로 실행하여 리소스를 필터링합니다.

<build> 
<!-- I dont want to add this here - I want to have it in execution 
    <resources> 
     <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     </resource> 
    </resources> 
    <filters> 
     <filter>config/1.properties</filter> 
    </filters> --> 
<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>3.0.0</version> 
     <executions> 
     <execution> 
      <id>1</id> 
      <phase>package</phase> 
      <configuration> 
       <filters> 
        <filter>config/1.properties</filter> 
       </filters> 
       <classifier>-1</classifier> 
       <webappDirectory>${project.build.directory}/${project.build.finalName}-1</webappDirectory> 
       <webResources> 
        <resource> 
        <directory>src/main/resources</directory> 
        <filtering>true</filtering> 
        </resource> 
       </webResources> 
      </configuration> 
      <goals> 
       <goal>war</goal> 
      </goals> 
     </execution> 
     <execution> 
      <id>2</id> 
      <phase>package</phase> 
      <configuration> 
       <filters> 
        <filter>config/2.properties</filter> 
       </filters> 
       <classifier>-2</classifier> 
       <webappDirectory>${project.build.directory}/${project.build.finalName}-2</webappDirectory> 
       <webResources> 
        <resource> 
        <directory>src/main/resources</directory> 
        <filtering>true</filtering> 
        </resource> 
       </webResources> 
      </configuration> 
      <goals> 
       <goal>war</goal> 
      </goals> 
     </execution> 
     </executions> 
    </plugin> 
</plugins> 
</build> 

실마리가 무엇입니까? 나는이 persistence.xml에 정의 된 태그 <jta-data-source>${ds-server-jta}</jta-data-source>에서 'DS-서버 JTA'변수를 필터링하고 싶었

├── myapp.war 
    │   ├── index.html │   
    │   ├── myapp.properties 
    │   ├── logback.xml 
    │   ├── META-INF 
    │   │   ├── persistence.xml  
    │   │   
    │   └── WEB-INF     
    │    ├── classes 
    │    │   ├── myapp.properties 
    │    │   ├── logback.xml 
    │    │   ├── META-INF 
    │    │   │   ├── persistence.xml 

: 같은

답변

0

받는다는 전쟁 - 플러그인에 의해 생성 된 .WAR 보인다. Maven-war-plugin은 META-INF에있는 persistence.xml 만 필터링했습니다. maven-war-plugin이이 .war을 META-INF로 생성했으며 하나의 persistence.xml 만 필터링 (WEB-INF/classes/META-INF/persistence.xml 중 하나)했습니다. 다음 :

<webResources> 
    <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     <targetPath>WEB-INF/classes</targetPath> 
    </resource> 
    <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
    </resource> 
</webResources> 

이것은 어떤 리소스를 필터링할지 명시 적으로 알려주며 두 파일은 필요에 따라 변경됩니다.

그러나 META-INF의 Persistence.xml은 내 응용 프로그램 서버 (Glassfish)에서 사용하지는 않지만 maven-war-plugin은 어쨌든 만듭니다. 서버가 사용하는 파일은 WEB-INF/classes/META-INF/persistence.xml입니다. 이제 내 .war의 appserver META-INF 카탈로그에서 사용하지 않는 첫 번째 매개 변수를 만들지 않으려 고 노력하고 있습니다.