我正在尝试使用Maven为我的项目设置集成测试环境,但是在运行“编译”目标时出现以下错误。
[错误]无法执行目标 org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources (默认资源)在项目mavenintegrationtest上:加载错误 属性文件 '/Users/xxx/dev/poc/java/mavenintegrationtest/profiles/dev/config.properties' -> [帮助1]
该错误似乎是在抱怨它在正确的位置找不到config.properties文件。由于某种原因,它已从文件路径中删除了“ src / main / resources”位。
所以正确的完整路径是
/Users/xxx/dev/poc/java/mavenintegrationtest/src/main/resources/profiles/dev/config.properties
但由于某种原因,它删除了src / main / resources,因此正在查找,
/Users/xxx/dev/poc/java/mavenintegrationtest/profiles/dev/config.properties
有谁知道是什么原因造成的?
我的POM如下所示,当取消注释以下“过滤器”标记时,会出现此错误,
<filter>${basedir}/profiles/${build.profile.id}/config.properties</filter>
我尝试删除$ {basedir}语句,但仍然遇到相同的错误。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>mavenintegrationtest</artifactId>
<version>1.0-SNAPSHOT</version>
<name>mavenintegrationtest</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<filters>
<filter>${basedir}/profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
<!-- Profile configuration -->
<profiles>
<!-- The configuration of the development profile -->
<profile>
<id>dev</id>
<!-- The development profile is active by default -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>dev</build.profile.id>
</properties>
</profile>
<!-- The configuration of the integration-test profile -->
<profile>
<id>integration-test</id>
<properties>
<build.profile.id>integration-test</build.profile.id>
</properties>
</profile>
</profiles>
</project>