java - 如何从外部 Maven 依赖项中添加排除某些包

标签 java security maven exception tomcat

我的应用程序依赖于一个外部 jar

  <dependency>
    <groupId>org.objectweb.joram</groupId>
    <artifactId>jftp</artifactId>
    <version>1.52</version>
  </dependency>

我主要对使用下面的包import net.sf.jftp.net.*

感兴趣

但是看起来这个 jar 也暴露了 org.apache.log4j 包中的某些类,导致将应用程序 war 文件部署到 tomcat 时出现以下异常

java.lang.SecurityException: 类 "org.apache.log4j.PropertyConfigurator"的签名者信息与同一包中其他类的签名者信息不匹配

有什么办法可以避免错误吗?

最佳答案

首先你可以使用

mvn dependency:tree

以准确查看 jftp 加载了哪些依赖项。然后,像这样排除那些你不想要的:

<dependency>
  <groupId>org.objectweb.joram</groupId>
  <artifactId>jftp</artifactId>
  <version>1.52</version>
  <exclusions>
    <exclusion>  <!-- declare the exclusion here -->
      <groupId>sample.ProjectB</groupId>
      <artifactId>Project-B</artifactId>
    </exclusion>
  </exclusions> 
</dependency>

关于java - 如何从外部 Maven 依赖项中添加排除某些包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19721087/

相关文章:

java - 该应用程序不会调整其组件的大小

java - 运行Java Servlet无法查看欢迎页面404错误

java - 错误: cannot use raw constructor reference with explicit type parameters for constructor

eclipse - 插件错误: execution not covered by lifecycle configuration

maven - 获取解析器错误 : inconsistent cell count within the table - while running tests in Parallel - Selenium Cucumber Maven framework with Junit

java - 在 Java 中通过 HTTP 代理创建 TLS 连接

node.js - 通过在服务器上重新运行玩家的操作来保护多层浏览器游戏的安全

node.js - 如何使用 nginx 设置 HttpOnly 响应 header ?

security - 使用Acegi安全性以脚本级别登录Grails应用

java - 如何使用 JUnit 在 Maven 项目中通过自定义类加载器加载相同的类两次