【问题标题】:java: package net.serenitybdd.core.pages does not existjava: 包 net.serenitybdd.core.pages 不存在
【发布时间】:2021-05-05 16:56:13
【问题描述】:

当我编译我的项目时,我得到了错误: “java:包 net.serenitybdd.core.pages 不存在” enter image description here

当我运行项目时,我收到错误: “无法传输工件 org.apache.maven.plugins: maven-enforcer-plugin: pom: 1.4 from / to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo .maven.apache.org / maven2 / org /apache/maven/plugins/maven-enforcer-plugin/1.4/maven-enforcer-plugin-1.4.pom" enter image description here

我的本​​地 PC 上有同样的项目,它可以正常工作。现在我将它传递到我的工作站,这发生了。 我正在检查,似乎 McAfee-Agent Antivirus 正在阻止它? enter image description here 如果您能帮助我,那就太好了,谢谢。

IDE IntelliJ - Proyecto Maven

这是我的 POM:

4.0.0

<groupId>org.example</groupId>
<artifactId>ToMapfre</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <serenity.version>2.0.54</serenity.version>
    <serenity.maven.version>2.0.54</serenity.maven.version>
    <serenity.cucumber.version>1.6.4</serenity.cucumber.version>
</properties>

<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>2.0.54</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <id>enforce</id>
                    <configuration>
                        <rules>
                            <AlwaysPass/>
                        </rules>
                        <fail>true</fail>
                    </configuration>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18</version>
            <configuration>
                <includes>
                    <include>**/*RunnerTest.java</include>
                </includes>
                <reuseForks>true</reuseForks>
                <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.maven.version}</version>
            <dependencies>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-core</artifactId>
                    <version>${serenity.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

【问题讨论】:

  • 您使用什么 IDE 版本?确保使用 2021.1.1 版本进行尝试。如果问题仍然存在,请澄清-您可以通过 Maven 从命令行构建吗?附上完整的idea.log file 看看会发生什么。
  • 我尝试了这些选项,但得到的信息相同。我一直在检查,我看到在我传递我的项目的远程机器上,IDE 没有库,由于某种原因它没有下载库。有什么理由不这样做吗?我该如何配置它?
  • 这个项目的命令行中mvn clean compile 命令的结果是什么?

标签: java maven intellij-idea


【解决方案1】:

试试这个:

  1. 删除 .idea 文件夹。
  2. 在 .m2/repository/ 中找到问题依赖项并将它们也删除。
  3. 比从 pom.xml 打开项目(从菜单 -> 打开 - 项目文件夹 -> pom.xml)

有时会有所帮助。

【讨论】:

  • 编译运行项目时出现同样的信息。
  • 您是否尝试过在 IntelliJ 中重新导入 maven 项目? (Ctrl-Shift-O 在 Windows 下)否则 re-import all maven projects 在 maven 选项卡下。
  • 我尝试了这些选项,但我得到了同样的信息。我已经在我的本地机器(个人)的 IDE 中验证了它是否有库。但是在我的远程机器中,我看到它没有库,由于某种原因它没有下载库,我知道 IDE 在编译时会下载它们,但是在这里它没有下载它们并且显示了包的消息。 .. 我该怎么办?
  • 您在 \.m2\settings.xml 中有任何自定义设置吗?此外,您可以尝试以下操作:在 Idea 中转到:文件 -> 设置 -> 构建、执行、部署 -> Maven -> 导入。为 importer 添加 VM 选项:-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true 在 Build, Execution, Deployment -> Maven -> Runner -> VM Options 中相同。
猜你喜欢
  • 2011-11-13
  • 1970-01-01
  • 2019-01-11
  • 2022-01-03
  • 2017-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-04
相关资源
最近更新 更多