我的 pom.xml 中有以下配置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>cassandra.rpcPort</portName>
<portName>cassandra.jmxPort</portName>
<portName>cassandra.storagePort</portName>
<portName>cassandra.stopPort</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<enableAssertions>true</enableAssertions>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/integration/**/*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cassandra-maven-plugin</artifactId>
<version>1.2.1-1</version>
<executions>
<execution>
<id>start-cassandra</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-cassandra</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>*.*</include>
</includes>
<filtering>true</filtering>
</testResource>
</testResources>
和属性文件有这一行 cassandra_host=127.0.0.1:${cassandra.rpcPort}
代码使用此属性连接到 cassandra 的实例。因此,每当我运行 mvn clean install 时,cassandra.rpcPort 会生成两次,一次在运行其余部分时生成,另一次在运行 cobertura 时生成。例如。
[INFO] Reserved port 60315 for cassandra.rpcPort
[INFO] Reserved port 60316 for cassandra.jmxPort
[INFO] Reserved port 60317 for cassandra.storagePort
[INFO] Reserved port 60318 for cassandra.stopPort
然后当 cobertura 奔跑时,
[INFO] Reserved port 60319 for cassandra.rpcPort
[INFO] Reserved port 60320 for cassandra.jmxPort
[INFO] Reserved port 60321 for cassandra.storagePort
[INFO] Reserved port 60322 for cassandra.stopPort
并且 cassandra-maven-plugin 生成一个 target/cassandra/conf/cassandra.yaml 文件,该文件具有 rpc_port: 60315 (原始端口,而不是来自 cobertura 的端口)。但是,属性文件具有 cobertura 生成的端口的值。
如果我禁用了 cobertura 插件,那么一切都会成功运行。有谁知道如何解决这个问题?
谢谢和问候锡