How do you replace the class of a Maven dependency?(如何替换 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
推荐答案
一般解决方案:
- 下载所有项目源代码
- 应用您的修改
- 使用版本控制,以免丢失更改
这篇关于如何替换 Maven 依赖项的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何替换 Maven 依赖项的类?


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01