什么是背书以及如何在应用程序中使用它?

Vij*_*bey 33 java maven

关于maven-compiler-plugin.我的项目的POM文件中添加了一个设置.配置如下.

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
            <compilerArguments>
                <endorseddirs>${endorsed.dir}</endorseddirs>
            </compilerArguments>
        </configuration>
    </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

<endorseddirs>在编译器参数中有一个含义是什么意思?它如何与java编译器一起使用?

Rag*_*ram 20

背书标准覆盖机制的文档中,它是一种提供的机制newer versions of an endorsed standard than those included in the Java 2 Platform

您的项目必须是创建和/或使用此类实现.

通过指定<endorseddirs>属性,您将指示java编译器查看此文件夹中存在的jar以覆盖标准jdk中类似定义的类.


ami*_*ula 10

通过Java文档,java.endorsed.dirs用于提供支持标准覆盖机制.这意味着,用户可以提供某些软件包的新版本,而不是JDK提供的软件包.如果在java.endorsed.dirs指定的目录中有这些包的较新实现,那么将加载这些实现而不是JDK附带的默认实现.

可以通过这种方式覆盖的软件包分为Endorsed Standards API和Standalone Technologies,并列在Java文档中.

粗略地说,背书标准API包括:

  • javax.rmi.CORBA中
  • 各种org.omg.*包
  • org.w3c.dom中
  • 各种org.xml.sax.*包

独立技术包括:

  • 用于XML处理的Java API(JAXP),版本1.4
  • 用于XML绑定的Java体系结构(JAXB),版本2.0
  • 用于基于XML的Web服务的Java API(JAX-WS),版本2.0
  • Java Compiler API,版本1.0
  • 可插入注释处理API,版本1.0
  • Java平台的通用注释,版本1.0
  • Java平台的脚本,版本1.0
  • SOAP with Attachments API for Java(SAAJ),版本1.3