프로젝트에서 속성 및 XML 파일을 포함하는 리소스 디렉토리 (src/main/resources
)가 있습니다.Eclipse에서 Maven2 프로젝트를 가져올 때 문제가 발생했습니다.
속성 파일 만 필터링하고 다른 종류의 파일 (예 : XML)은 필터링하지 않습니다. 따라서, 나는이를 설정 한 내 pom.xml
:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
</build>
내가 메이븐 2 패키지 명령을 실행할 때이 잘 작동하고는, 즉, XML 및 속성을 두 파일이 내 마지막 JAR에 포함되며, 전용 속성의 파일이왔다 거르는.
그러나이 프로젝트를 Eclipse에 포함하려는 경우 mvn eclipse:eclipse
명령을 실행하고 프로젝트를 가져올 때 프로젝트 속성에 선언 된 소스에 문제가 있습니다. 탭 "소스"내 프로젝트에 대한 이클립스의 "자바 빌드 경로"옵션에서
, 나는 src/main/resources
디렉토리를 볼 수 있지만, Eclipse는 모든 자바 파일 (Excluded: **/*.java
)을 제외 말하고 만 포함 필터를 추가 속성 파일 (Included: **/*.properties
). 내 모든 XML 파일은 JAR에없는 것처럼
<classpathentry kind="src" path="src/main/resources" including="**/*.properties" excluding="**/*.java"/>
이 방법, 이클립스에 의해 만들어진 JAR가 정확하지 : 생성 된 .classpath
파일에서
이 문제를 어떻게 해결할 수 있습니까?
편집이 page에 대하여, 나는이를 추가 한 내 pom.xml
:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.6</version>
<configuration>
<sourceIncludes>
<sourceInclude>**/*.xml</sourceInclude>
</sourceIncludes>
</configuration>
</plugin>
</plugins>
그러나, 적절한 정보와 수정되지 않습니다 생성 된 .classpath ...
다시 수정하십시오.
이전 편집의 추가 사항은 Eclipse 플러그인의 2.6.1 이상 버전에서만 작동하며 2.6 버전에서는 작동하지 않습니다. 그래서 저는 2.7 버전을 사용해 보았습니다. 그러나, 나는 포함 속성을 정의하지 이클립스 플러그인을 강제하는 방법을 모른다 :
Request to merge when 'filtering' is not identical. Original=resource src/main/resources: output=target/classes, include=[**/*.properties], exclude=[**/*.java], test=false, filtering=true, merging with=resource src/main/resources: output=target/classes, include=[], exclude=[**/*.properties|**/*.java], test=false, filtering=false
난 당신이 코드에서 실수를 생각 - 둘 다 포함 할합니다. '* .properties' 파일을 제외 하시겠습니까? –
실수가 아닙니다. 리소스의 두 가지 하위 집합이 있습니다. s : 첫 번째 것은'properties' 파일과 * filter *만을 포함합니다. 두 번째 것은'properties' 파일 만 제외하고 *는 그것들을 필터링하지 않습니다. 이것은'src/main/resources'에있는 모든 파일을 포함하고 그 중 일부만을 필터링하는 유일한 방법입니다 ... – romaintaz
맞습니다. 지금 당장 받으십시오. –