如何替换 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:
- 创建一个同名的包
- 在该包中创建一个同名的类
- 复制并粘贴代码
- 修复不兼容的 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
推荐答案
一般解决方案:
- 下载所有项目源代码
- 应用您的修改
- 使用版本控制,以免丢失更改
相关文章