【问题标题】:Creation of a java EE project on Eclipse for Java EE在 Eclipse 上为 Java EE 创建一个 Java EE 项目
【发布时间】:2022-01-14 01:07:27
【问题描述】:

我已经使用 maven 创建了一个 Java EE 项目。

Here is the generated hierarchy

如果您在此图像上观察,我在 index.jsp 文件中发现错误。 当我专注于错误时,我得到: The superclass "jakarta.servlet.http.HttpServlet" was not found on the Java Build Path.

Error message in index.jsp

有人可以帮我解决吗?谢谢。

这是自动生成的 pom.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<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>tn.ipsas.jee_eclipse</groupId>
  <artifactId>maven_jsf_wepp_app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>maven_jsf_wepp_app Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>maven_jsf_wepp_app</finalName>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

【问题讨论】:

  • Project > Properties: Java Build Path 中似乎有问题。由于是 Maven 项目,请出示您的 pom.xml 文件。

标签: eclipse maven java-ee-5


【解决方案1】:

Here is how I solved the problem. 右键单击项目,Property> Project Facets 选择动态 Web 模块,我将版本升级到 3.1 然后申请

【讨论】:

  • 原来的值是多少?
  • 它是低版本的动态 Web 模块