我在SO上阅读了这个问题,但找不到合适的答案,这对我有好处。所以,我写了mvn项目,项目中的结构是这样的:
+ src / test / java(包含测试类的包)
+ src / main / java(包含一些辅助类的包)
我定义了所有环境var:
M2_HOME = C:\ Program Files \ apache-maven-3.5.0,
MAVEN_HOME = C:\ Program Files \ apache-maven-3.5.0,
JAVA_HOME = C:\ Program Files \ Java \ jdk1.8.0_111。
cmd结果:
java -version
java版“1.8.0_111” Java(TM)SE运行时环境(版本1.8.0_111-b14) Java HotSpot(TM)64位服务器VM(版本25.111-b14,混合模式)
mvn -v
Apache Maven 3.5.0(ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06 + 02:00) Maven home:C:\ Program Files \ apache-maven-3.5.0 \ bin .. Java版本:1.8.0_111,供应商:Oracle Corporation Java home:c:\ Program Files \ Java \ jdk1.8.0_111 \ jre 默认语言环境:en_GB,平台编码:Cp1252 操作系统名称:“windows 10”,版本:“10.0”,arch:“amd64”,系列:“windows”
javac -version
javac 1.8.0_111
的pom.xml
str_to_int
错误:
<repositories>
<repository>
<id>atlassian.com</id>
<name>Atlassian</name>
<url>http://maven.atlassian.com/public</url>
<layout>default</layout>
</repository>
<!-- <repository> -->
<!-- <id>maven2-repository.dev.java.net</id> -->
<!-- <name>Java.net Repository for Maven</name> -->
<!-- <url>http://download.java.net/maven/2/</url> -->
<!-- <layout>default</layout> -->
<!-- </repository> -->
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>1.2.2</cucumber.version>
<selenium.version>3.0.1</selenium.version>
<junit.version>4.12</junit.version>
<atr.version>1.2.3</atr.version>
<rest.version>2.4.0</rest.version>
<jira.version>1000.824.2</jira.version>
<jira.data.version>1000.824.2</jira.data.version>
<amps.version>5.0.4</amps.version>
<plugin.testrunner.version>1.2.0</plugin.testrunner.version>
<testkit.version>6.0.51</testkit.version>
</properties>
<build>
<!-- <testSourceDirectory>src/test/java</testSourceDirectory> -->
<plugins>
<!-- <plugin> -->
<!-- <artifactId>maven-assembly-plugin</artifactId> -->
<!-- <version>2.2.1</version> -->
<!-- <configuration> -->
<!-- <descriptorRefs> -->
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
<!-- </descriptorRefs> -->
<!-- <archive> -->
<!-- <manifest> -->
<!-- <mainClass>gov.grantsolutions.pmo.App</mainClass> -->
<!-- </manifest> -->
<!-- </archive> -->
<!-- </configuration> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>make-assembly</id> -->
<!-- <phase>package</phase> -->
<!-- <goals> -->
<!-- <goal>single</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-surefire-plugin</artifactId> -->
<!-- <version>2.20</version> -->
<!-- <configuration> -->
<!-- <suiteXmlFiles> -->
<!-- <suiteXmlFile>test_logging.xml</suiteXmlFile> -->
<!-- </suiteXmlFiles> -->
<!-- </configuration> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-resources-plugin</artifactId> -->
<!-- <version>2.6</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <phase>test</phase> -->
<!-- <goals> -->
<!-- <goal>resources</goal> -->
<!-- <goal>testResources</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/ojdbc/ojdbc -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit-addons/junit-addons -->
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.30</version>
</dependency>
<dependency>
<groupId>org.bluestemsoftware.open.maven.tparty</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.25</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.sun.xml.bind</groupId> -->
<!-- <artifactId>jaxb-impl</artifactId> -->
<!-- <version>2.1.12</version> -->
<!-- </dependency> -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>javax.xml</groupId> -->
<!-- <artifactId>jaxb-api</artifactId> -->
<!-- <version>2.1</version> -->
<!-- </dependency> -->
<dependency>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
<version>1.0-2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.lightbody.bmp/browsermob-core-littleproxy -->
<!-- <dependency> <groupId>net.lightbody.bmp</groupId> <artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-6</version> </dependency> -->
</dependencies>
答案 0 :(得分:0)
问题解决了。这条痕迹,隐藏了答案的关键:
[ERROR] /C:/git/Selenium/Selenium.git/AcceptanceTestSuite/src/main/java/com/mozzartbet/qa/utils/Common.java:[27,35] 包com.mozzartbet.qa.testCases不存在
在测试类的Common类I实例对象中?!?为什么我这样做?我不知道。无论如何,一切都与Java版本,Java编译器(编译器设置),dependecies一致。所以我封装了Common类,现在它不依赖于测试用例类,并且一切正常。 :)