如何替换 Maven 依赖项的类?

How do you replace the class of a Maven dependency?(如何替换 Maven 依赖项的类?)
本文介绍了如何替换 Maven 依赖项的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

maven 依赖中有一个类与 Java 8 不兼容.

There is a class in a maven dependency that is incompatible with Java 8.

您如何正确解决该问题?

How do you properly fix that problem?

现在我正在做以下事情:

Right now I'm doing the following:

  1. 创建一个同名的包
  2. 在该包中创建一个同名的类
  3. 复制并粘贴代码
  4. 修复不兼容的 API 调用

问题是这个类包含对受限类的 API 调用,尽管我更改了 Eclipse 编译器设置(Window -> Preferences -> Java -> Compiler -> Error/Warnings -> Deprecated and restricted API -> Forbidden reference (访问规则):错误->警告)允许访问该项目有时只会编译.如果它没有编译,我会得到一个找不到符号"的错误.

The problem is that this class contains API calls to restricted classes and although I changed the Eclipse compiler settings (Window -> Preferences -> Java -> Compiler -> Error/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule): Error -> Warning) to allow access the project will only compile sometimes. If it doesn't compile I'll get a "can't find symbol" error.

以下是您要求的详细信息:

Here are the details you asked for:

  • 依赖:http://mvnrepository.com/artifact/com.sun.xml.wss/xws-security/3.0

类:加密处理器

必要的改变:

// Change line 1053 FROM: 
// _dataEncryptor = XMLCipher.getInstance(dataEncAlgo, _dataCipher); 
// TO:
_dataEncryptor = XMLCipher.getInstance(dataEncAlgo); 

Edit-2:

Maven 构建错误:

Maven build error:

 [ERROR] symbol:   class XMLCipher
 [ERROR] location: class com.sun.xml.wss.impl.apachecrypto.EncryptionProcessor
 [ERROR] /C:/Users/{name}/development/eclipse_workspace/git/xws-security/src/main/java/com/sun/xml/wss/impl/apachecrypto/EncryptionProcessor.java:[1482,98] cannot find symbol

推荐答案

一般解决方案:

  • 下载所有项目源代码
  • 应用您的修改
    • 使用版本控制,以免丢失更改

    这篇关于如何替换 Maven 依赖项的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

JPMS/Jigsaw Missing Main Class in Module(JPMS/Jigsaw模块中缺少主类)
Can not run JAVAFX .jar File (many errors occurred)(无法运行JavaFX.jar文件(出现许多错误))
JPMS and fatuber executable JAR - how it works together?(JPMS和FATUBER可执行JAR--它是如何协同工作的?)
Use jdk.internal.net.http(使用jdk.inder.net.http)
javax.annotation classes and Java 11 JDK(Javax.Annotation类和Java 11 JDK)
Are Filer#39;s originating elements useful?(FILLER的原始元素有用吗?)