如何替换Maven依赖关系的类? [英] How do you replace the class of a Maven dependency?
问题描述
如何正确解决这个问题?
现在我正在做以下操作:
- 创建一个包相同的名称
- 在该包中创建同名的课程
- 复制并粘贴代码
- 修复不兼容的API调用
问题是该类包含对受限类的API调用,尽管我更改了Eclipse编译器设置窗口 - >首选项 - > Java - >编译器 - >错误/警告 - >已弃用和限制的API - >禁止引用(访问规则):错误 - >警告)允许访问项目只会有时进行编译。如果没有编译,我会得到一个找不到符号的错误。
编辑:
以下是您要求的详细信息:
-
依赖关系: http://mvnrepository.com/artifact/com.sun.xml.wss/xws-security/3.0
-
类:加密处理器
-
必要更改:
//更改行1053 FROM:
// _dataEncryptor = XMLCipher.getInstance(dataEncAlgo,_dataCipher);
// TO:
_dataEncryptor = XMLCipher.getInstance(dataEncAlgo);
编辑-2:
Maven构建错误:
[ERROR]符号:class XMLCipher
[错误]位置: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]找不到符号
一般解决方案:
- 下载所有项目来源
- 应用您的修改
-
- 使用版本控制,以使更改不丢失
- 在
pom.xml
中更改版本,例如从3.0
code> 3.0补丁 - 启动maven构建
- 将生成的工件复制到您的存储库/ Artifactory,如果您在自己的项目中使用一个
- 更改依赖关系版本
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:
- Create a package with the same name
- Create a class with the same name in that package
- Copy and paste the code
- Fix the incompatible API call
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.
Edit:
Here are the details you asked for:
Dependency: http://mvnrepository.com/artifact/com.sun.xml.wss/xws-security/3.0
Class: EncryptionProcessor
Necessary change:
// Change line 1053 FROM: // _dataEncryptor = XMLCipher.getInstance(dataEncAlgo, _dataCipher); // TO: _dataEncryptor = XMLCipher.getInstance(dataEncAlgo);
Edit-2:
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
General solution:
- download all project sources
- apply your modification
- use version control so that change isn't lost
- change version in
pom.xml
, for example from3.0
to3.0-patched
- launch maven build
- copy generated artifacts to you repository/Artifactory, if you use one
- change dependency version in your own project
这篇关于如何替换Maven依赖关系的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!