如何替换 Maven 依赖项的类? [英] How do you replace the class of a Maven dependency?

查看:65
本文介绍了如何替换 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:

类:加密处理器

必要的改变:

// 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 依赖项的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆