0

我正在尝试使用 Eclipse 构建一个 Maven 项目,我正在使用命令“干净安装”来构建这个应用程序,但是我得到了如下所示的错误。

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/maven-v4_0_0.xsd">
    <parent>
        <groupId>ma.manager.backoffice</groupId>
        <artifactId>bookManager</artifactId>
        <version>1.0</version>
        <relativePath>../bookManager</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>bookManager</artifactId>
    <packaging>war</packaging>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/config/${env}</directory>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>           
        </plugins>
    </build>
    <dependencies>  

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.8.1</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-csv</artifactId>
    <version>2.8.9</version>
</dependency>
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>2.5.16</version>
</dependency>
<dependency>
    <groupId>com.opensymphony</groupId>
    <artifactId>xwork</artifactId>
    <version>2.1.3</version>
</dependency>
</dependencies>
</project>

我已经尝试了这些步骤:

  • 更新项目;

  • 清理项目然后运行全新安装

  • 手动下载依赖

  • 多次导入项目

  • 检查java版本:

在此处输入图像描述

    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  1.956 s
    [INFO] Finished at: 2020-07-01T08:40:27+01:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project bookManager: Compilation failure: Compilation failure: 
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[5,48] package org.apache.struts2.convention.annotation does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[6,48] package org.apache.struts2.convention.annotation does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[7,38] package org.apache.struts2.interceptor does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[9,31] package com.opensymphony.xwork2 does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[13,32] cannot find symbol
    [ERROR]   symbol: class ActionSupport
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[13,57] cannot find symbol
    [ERROR]   symbol: class SessionAware
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[11,2] cannot find symbol
    [ERROR]   symbol: class Namespace
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[12,2] cannot find symbol
    [ERROR]   symbol: class ParentPackage
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[8,31] package com.opensymphony.xwork2 does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[9,31] package com.opensymphony.xwork2 does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[10,36] package com.opensymphony.xwork2.util does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[12,39] cannot find symbol
    [ERROR]   symbol: class ActionSupport
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[4,25] package javax.servlet.jsp does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[5,32] package javax.servlet.jsp.tagext does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[9,33] cannot find symbol
    [ERROR]   symbol: class TagSupport
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[16,40] cannot find symbol
    [ERROR]   symbol:   class JspException
    [ERROR]   location: class ma.manager.backoffice.tag.Category
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[3,48] package org.apache.struts2.convention.annotation does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[4,48] package org.apache.struts2.convention.annotation does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[5,48] package org.apache.struts2.convention.annotation does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[6,48] package org.apache.struts2.convention.annotation does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[8,31] package com.opensymphony.xwork2 does not exist
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[13,36] cannot find symbol
    [ERROR]   symbol: class ActionSupport
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[11,2] cannot find symbol
    [ERROR]   symbol: class Namespace
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[12,2] cannot find symbol
    [ERROR]   symbol: class ParentPackage
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[22,10] cannot find symbol
    [ERROR]   symbol:   class Action
    [ERROR]   location: class ma.manager.backoffice.action.WelcomeAction
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[28,10] cannot find symbol
    [ERROR]   symbol:   class Action
    [ERROR]   location: class ma.manager.backoffice.action.WelcomeAction
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/WelcomeAction.java:[35,10] cannot find symbol
    [ERROR]   symbol:   class Action
    [ERROR]   location: class ma.manager.backoffice.action.WelcomeAction
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/MasterAction.java:[15,9] method does not override or implement a method from a supertype
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[21,5] method does not override or implement a method from a supertype
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[24,9] cannot find symbol
    [ERROR]   symbol:   class ActionContext
    [ERROR]   location: class ma.manager.backoffice.action.exception.ExceptionHandler
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[24,28] cannot find symbol
    [ERROR]   symbol:   variable ActionContext
    [ERROR]   location: class ma.manager.backoffice.action.exception.ExceptionHandler
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[25,9] cannot find symbol
    [ERROR]   symbol:   class ValueStack
    [ERROR]   location: class ma.manager.backoffice.action.exception.ExceptionHandler
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[30,17] cannot find symbol
    [ERROR]   symbol:   method addActionError(java.lang.String)
    [ERROR]   location: class ma.manager.backoffice.action.exception.ExceptionHandler
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[35,17] cannot find symbol
    [ERROR]   symbol:   method addActionError(java.lang.String)
    [ERROR]   location: class ma.manager.backoffice.action.exception.ExceptionHandler
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/action/exception/ExceptionHandler.java:[41,25] cannot find symbol
    [ERROR]   symbol:   method addActionError(java.lang.String)
    [ERROR]   location: class ma.manager.backoffice.action.exception.ExceptionHandler
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[20,25] cannot find symbol
    [ERROR]   symbol:   variable pageContext
    [ERROR]   location: class ma.manager.backoffice.tag.Category
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[25,35] cannot find symbol
    [ERROR]   symbol:   class JspException
    [ERROR]   location: class ma.manager.backoffice.tag.Category
    [ERROR] /D:/Category/bookManager/src/main/java/ma/manager/backoffice/tag/Category.java:[27,24] cannot find symbol
    [ERROR]   symbol:   variable SKIP_BODY
    [ERROR]   location: class ma.manager.backoffice.tag.Category
    [ERROR] -> [Help 1]
4

1 回答 1

1

更新:

从快照来看,您的 JRE 系统库似乎设置为 Java SE 1.7,而 JAR 的版本为 1.8.0_251。在 POM 中,将 Source 和 Target 版本更改为 1.8。另外请删除已安装的 JRE 并将其更改为 JDK 1.8.0_251。之后进行项目清理和重建。

单击删除,然后添加库。

选择您拥有的 JDK 1.8

还要检查编译器级别:


可能你缺少一些依赖项(因为日志说一些包没有找到)你的 pom.xml 中有这些依赖项吗?

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>2.5.22</version>
</dependency>
<dependency>
    <groupId>com.opensymphony</groupId>
    <artifactId>xwork</artifactId>
    <version>2.1.3</version>
</dependency>

于 2020-07-01T08:13:34.323 回答