Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java &引用;mvn测试“;在控制台中给出不同的错误_Java_Maven_Pom.xml - Fatal编程技术网

Java &引用;mvn测试“;在控制台中给出不同的错误

Java &引用;mvn测试“;在控制台中给出不同的错误,java,maven,pom.xml,Java,Maven,Pom.xml,我一直面临这三个错误: java:[8,40]错误:找不到符号 Users.java:[5,25]错误:包com.project.tests不存在 找不到侦听器类 我转到这些行,发现行8,40有此错误,因为它在这一行找不到变量(符号)。对于第二个错误,我转到该行,它是import com.project.tests.Repo 在源文件夹src/test/java中有两个包import com.project.tests,在src/main/java中有import com.project.liv

我一直面临这三个错误:

  • java:[8,40]错误:找不到符号
  • Users.java:[5,25]错误:包com.project.tests不存在
  • 找不到侦听器类
  • 我转到这些行,发现行8,40有此错误,因为它在这一行找不到变量(符号)。对于第二个错误,我转到该行,它是
    import com.project.tests.Repo

    在源文件夹
    src/test/java
    中有两个包
    import com.project.tests
    ,在
    src/main/java
    中有
    import com.project.live
    。因此,它可以找到
    import com.project.live
    ,但不能找到
    import com.project.tests
    com.project.tests.Repo位于包
    导入com.project.tests
    中,这就是它给出错误的原因。

    在阅读stackoverflow.com和其他论坛上的不同帖子时,我发现前两个错误可以通过将
    maven compiler plugin
    更新为
    Version3.1
    并将
    testng
    更新为最新版本来修复。昨天我做了更改并进行了测试,所以两个错误都被删除了,它开始出现#3错误。
    但是今天当我进行
    mvn测试时,接着是
    mvn clean
    ,它有时同时出现错误1和2,有时单独出现错误3。
    我不明白发生了什么。为了摆脱这个问题,我删除了
    .m2
    ,并使用
    mvn安装重新获得它
    ,但没有改变,它的行为一直很奇怪。
    我将
    pom.xml
    粘贴到下面:

    <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.project.tests</groupId>
        <artifactId>project</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
        <name>project</name>
        <url>http://maven.apache.org</url>
        <build>
            <testResources>
                <testResource>
                    <directory>src/test/resource</directory>
                    <excludes>
                        <exclude>**/*.java</exclude>
                    </excludes>
                </testResource>
            </testResources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <fork>true</fork>
                        <executable>${JAVA_HOME}/bin/javac</executable>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>ch.fortysix</groupId>
                    <artifactId>maven-postman-plugin</artifactId>
                    <version>0.1.6</version>
                    <executions>
                        <execution>
                            <id>send a mail</id>
                            <phase>test</phase>
                            <goals>
                                <goal>send-mail</goal>
                            </goals>
                            <inherited>false</inherited>
                            <configuration>
                                <from>
                                    myofficial@emailid.com
                                </from>
                                <subject>
                                    Test Results
                                </subject>
                                <failonerror>
                                    true
                                </failonerror>
                                <mailhost>
                                </mailhost>
                                <receivers>
                                    <receiver>myofficial2@emailid.com</receiver>
                                </receivers>
                                <htmlMessageFile>
                                    /var/lib/jenkins/jobs/Testing/workspace/target/surefire-reports/emailable-report.html
                                </htmlMessageFile>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <!-- Maven suerfire config -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.14.1</version>
                    <configuration>
                        <forkCount>0</forkCount>
                        <suiteXmlFiles>
                            <suiteXmlFile>
                                /home/ubuntu/automation/projectAutomate/Chrome.xml
                            </suiteXmlFile>
                        </suiteXmlFiles>
                        <testFailureIgnore>
                            true
                        </testFailureIgnore>
    
                        <properties>
    
                            <property>
                                <name>listener</name>
                                <value>
                                    org.uncommons.reportng.HTMLReporter,
                                    org.uncommons.reportng.JUnitXMLReporter
                                </value>
                            </property>
                        </properties>
                        <workingDirectory>target/</workingDirectory>
                    </configuration>
    
    
    
                </plugin>
    
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>2.16</version>
                </plugin>
            </plugins>
        </build>
    
        <reporting>
            <plugins>
                <!-- TestNG-xslt related configuration. -->
                <plugin>
                    <groupId>org.testng.xslt</groupId>
                    <artifactId>testng-xslt-plugin</artifactId>
                    <version>1.1</version>
                    <configuration>
                        <!-- Output directory for the report -->
                        <outputDir>
                            /var/lib/jenkins/jobs/DailySignUpTests/workspace/target/testng-xslt-report/
                        </outputDir>
                        <sortTestCaseLinks>true</sortTestCaseLinks>
                        <testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter>
                        <showRuntimeTotals>true</showRuntimeTotals>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <properties>
                            <property>
                                <name>usedefaultlisteners</name>
                                <value>false</value>
                            </property>
                            <property>
                                <name>listener</name>
                                <value>
                                    org.uncommons.reportng.HTMLReporter,
                                    org.uncommons.reportng.JUnitXMLReporter
                                </value>
                            </property>
                        </properties>
                        <workingDirectory>target/</workingDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </reporting>
    
        <properties>
            <project.build.sourceEncoding>
                UTF-8
            </project.build.sourceEncoding>
        </properties>
        <dependencies>
            <!-- first -->
    
    
    
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-server</artifactId>
                <version>2.34.0</version>
            </dependency>
    
    
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>2.34.0</version>
            </dependency>
    
    
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-support</artifactId>
                <version>2.34.0</version>
            </dependency>
    
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-api</artifactId>
                <version>2.34.0</version>
            </dependency>
    
    
            <dependency>
                <groupId>org.hudsonci.plugins</groupId>
                <artifactId>testng-plugin</artifactId>
                <version>0.32-h-1</version>
            </dependency>
    
            <dependency>
                <groupId>velocity</groupId>
                <artifactId>velocity</artifactId>
                <version>1.4</version>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <groupId>org.uncommons</groupId>
                <artifactId>reportng</artifactId>
                <version>1.1.2</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>3.0</version>
                <scope>test</scope>
            </dependency>
    
    
            <!-- second -->
            <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.5.2</version>
            </dependency>
            <!-- third -->
            <dependency>
                <groupId>net.sourceforge.jexcelapi</groupId>
                <artifactId>jxl</artifactId>
                <version>2.6.12</version>
            </dependency>
            <dependency>
                <groupId>com.github.detro.ghostdriver</groupId>
                <artifactId>phantomjsdriver</artifactId>
                <version>1.0.4</version>
            </dependency>
            <dependency>
                <groupId>
    org.slf4j
              </groupId>
                <artifactId>
    nlog4j
              </artifactId>
                <version>
    1.2.25
              </version>
            </dependency>
        </dependencies>
    
        <repositories>
            <repository>
                <id>java-net</id>
                <url>http://download.java.net/maven/2</url>
            </repository>
        </repositories>
    
    </project>
    
    
    4.0.0
    com.project.tests
    项目
    0.0.1-快照
    罐子
    项目
    http://maven.apache.org
    src/测试/资源
    **/*.爪哇
    org.apache.maven.plugins
    maven编译器插件
    3.1
    1.7
    1.7
    真的
    ${JAVA_HOME}/bin/javac
    UTF-8
    福提西教堂
    maven邮递员插件
    0.1.6
    寄信
    测试
    寄信
    假的
    myofficial@emailid.com
    测试结果
    真的
    myofficial2@emailid.com
    /var/lib/jenkins/jobs/Testing/workspace/target/surefire reports/emailable-report.html
    org.apache.maven.plugins
    maven surefire插件
    2.14.1
    0
    /home/ubuntu/automation/projectautomation/Chrome.xml
    真的
    听众
    org.uncommons.reportng.HTMLReporter,
    org.uncommons.reportng.JUnitXMLReporter
    目标/
    org.apache.maven.plugins
    maven surefire报告插件
    2.16
    org.testng.xslt
    testngxslt插件
    1.1
    /var/lib/jenkins/jobs/DailySignUpTests/workspace/target/testng xslt报告/
    真的
    失败、跳过、通过、配置、按类
    真的
    org.apache.maven.plugins
    maven surefire插件
    2.5
    usedefaultlisteners
    假的
    听众
    org.uncommons.reportng.HTMLReporter,
    org.uncommons.reportng.JUnitXMLReporter
    目标/
    UTF-8
    org.seleniumhq.selenium
    硒服务器
    2.34.0
    org.seleniumhq.selenium
    硒爪哇
    2.34.0
    org.seleniumhq.selenium
    硒载体
    2.34.0
    org.seleniumhq.selenium
    硒原料药
    2.34.0
    org.hudsonci.plugins
    testng插件
    0.32-h-1
    速度
    速度
    1.4
    测试