java我的POM怎么了?“解析表达式..检测到递归表达式循环”
我有一些TestNG SuiteXML文件,其中包含如下运行时参数:-
<!--SERVER AND TARGET PARAMS-->
<parameter name="environment" value="${environment}"/>
<parameter name="port" value="${port}"/>
我的POM看起来是这样的:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd“>; 4.0.0
<groupId>co.uk.multicom.test.project</groupId>
<artifactId>fab-handler-automation</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<sl4j.version>1.7.7</sl4j.version>
<suiteFile>${suiteFile}</suiteFile>
<environment>${environment}</environment>
<port>${port}</port>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<systemProperties>
<property>
<name>javax.xml.parsers.SAXParserFactory</name>
<value>org.apache.xerces.jaxp.SAXParserFactoryImpl</value>
</property>
<property>
<name>user.language</name>
<value>en</value>
</property>
</systemProperties>
<!--<testFailureIgnore>true</testFailureIgnore>-->
<suiteXmlFiles>
<suiteXmlFile>${suiteFile}</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<environment>${environment}</environment>
<port>${port}</port>
</systemPropertyVariables>
<properties>
<property>
<name>parallel</name>
<value>methods</value>
</property>
<property>
<name>threadCount</name>
<value>1</value>
</property>
<property>
<name>dataproviderthreadcount</name>
<value>1</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.jayway.restassured/rest-assured -->
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- pom.xml -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
我的错误是:
[ERROR] Resolving expression: '${environment}': Detected the following recursive expression cycle in 'environment': [environment] -> [Help 2]
[ERROR] Resolving expression: '${port}': Detected the following recursive expression cycle in 'port': [port] -> [Help 2]
我是不是很蠢?也许,我毕竟只是一名测试人员,而且大脑非常小。有人能帮我排除故障吗?我的POM看起来蓬松吗
它不会将我所需的JAR下载到本地。m2,直到我能修好它——我已经试着吹走了。m2和mvn安装等。。。。没有欢乐
# 1 楼答案
你的错误来自这一部分:
当您使用${port}时,Maven会在
<port>X</port>
中查找值,这里的X=${port}等等。。。这就是为什么这里有一个递归问题# 2 楼答案
我不确定,因为我只有时间快速查看,但定义一个属性,然后将该属性分配给它自己,这是我认为您所做的,也是导致错误的原因
你不能只在pom中使用${suiteFile},而不在
<properties></properties>
中定义它吗或者可以在pom中使用其他属性名称? 例如:
在你的pom中使用这些
# 3 楼答案
我今天遇到了同样的问题。更有趣的是,那是在我几分钟前成功执行了同一个项目之后。事实证明,构建配置在命令(clean package等)被写入概要文件时出错
这是一个愚蠢的错误,但却让我花了一些时间,而它之所以能更早地工作,是因为我手动输入了命令,而不是使用保存的构建配置