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

查看:588
本文介绍了如何替换Maven依赖关系的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何正确解决这个问题?



现在我正在做以下操作:


  1. 创建一个包相同的名称

  2. 在该包中创建同名的课程

  3. 复制并粘贴代码

  4. 修复不兼容的API调用

问题是该类包含对受限类的API调用,尽管我更改了Eclipse编译器设置窗口 - >首选项 - > Java - >编译器 - >错误/警告 - >已弃用和限制的API - >禁止引用(访问规则):错误 - >警告)允许访问项目只会有时进行编译。如果没有编译,我会得到一个找不到符号的错误。



编辑:



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





编辑-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:

  1. Create a package with the same name
  2. Create a class with the same name in that package
  3. Copy and paste the code
  4. 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:

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 from 3.0 to 3.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屋!

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