“el-api”在 pom.xml 中什麼時候有用? (When is "el-api" useful in pom.xml?)


問題描述

“el‑api”在 pom.xml 中什麼時候有用? (When is "el‑api" useful in pom.xml?)

我在 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 
                        https://maven.apache.org/xsd/maven‑4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.jsf</groupId>
    <artifactId>showcase</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

    <name>showcase</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>prime‑repo</id>
            <name>Prime Repo</name>
            <url>http://repository.primefaces.org</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>7.0</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld‑servlet‑shaded</artifactId>
            <version>3.1.3.Final</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee‑web‑api</artifactId>
            <version>8.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.faces</artifactId>
            <version>2.3.14</version>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet.jsp.jstl</groupId>
            <artifactId>jakarta.servlet.jsp.jstl‑api</artifactId>
            <version>1.2.7</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven‑compiler‑plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <encoding>UTF‑8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven‑war‑plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

什麼時候出現:

<dependency>
    <groupId>jakarta.el</groupId>
    <artifactId>jakarta.el‑api</artifactId>
    <version>3.0.3</version>
    <scope>provided</scope>
</dependency>

有用嗎? 我在我的 pom.xml 中嘗試了使用和不使用這種依賴關係,並且沒有什麼變化。就我而言,在這兩種情況下一切正常。有沒有這種依賴關係的缺失會產生錯誤的情況? .................... ......


參考解法

方法 1:

It's indeed already covered by javaee‑web‑api. It's only useful during working in an IDE if the target server actually uses it, and it's in pom declared before the javaee‑web‑api. When done so, then you will in the IDE:

  • See javadocs from that API during code autocomplete
  • See source code from that API during debug‑stepping into the API classes

  • </ul>

    And even then it will be only useful if it actually contains improvements/fixes as compared to the ones in javaee‑web‑api. But when it's declared after the javaee‑web‑api in pom, then the ones in javaee‑web‑api will be used instead, and you might see the wrong javadocs and/or source code as compared to the ones used by the target server while working in the IDE. In such case the child API (be it EL API, or Servlet API, or JSF API, or whatever else), will indeed become utterly useless in pom.

    See also:


    Unrelated to the concrete problem, the javaee‑web‑api has been migrated to jakarta.jakartaee‑web‑api. Update your pom accordingly.

    (by Mario PalumboBalusC)

    參考文件

    1. When is "el‑api" useful in pom.xml? (CC BY‑SA 2.5/3.0/4.0)

#maven-3 #jsf #cdi #el






相關問題

Maven <include> wildcard cocok dengan nama folder parsial (Maven <include> wildcard match on partial folder name)

Eclipse 中使用 MAVEN 3.04 的動態 Web 應用程序 (Dynamic web application in eclipse using MAVEN 3.04)

Множныя рэпазітары Maven3 (Maven3 multiple repos)

замена ўласцівасці архетыпа maven (maven archetype property substitution)

Maven 發布和版本 Maven 插件 (Maven release and versions maven plugin)

Maven-glassfish-plugin:如何指定部署目標? (Maven-glassfish-plugin: how to specify deploy target?)

在 Maven WAR 構建中添加其他類 (Adding Additional classes in maven WAR build)

分佈式 Jenkins - Linux 上的主控和 Windows 上的從屬 - 如何配置節點特定設置 (Distributed Jenkins- Master on Linux and slave on windows- How to configure node specific setting)

如何觸發Maven SCM插件根據現有目錄自動切換目標? (How to trigger Maven SCM plugin to automatically switch goals based on existing directory?)

使用 MongoDB 存儲數據的 Java 應用程序是否需要 Maven? (Is Maven necessary for a Java application that uses MongoDB to store data?)

“el-api”在 pom.xml 中什麼時候有用? (When is "el-api" useful in pom.xml?)

無法在 JDK7 上運行 Maven 3.6.3 (Can't run Maven 3.6.3 on JDK7)







留言討論