电信项目遇到的问题----->>><2> java.lang.NoSuchMethodError问题处理

本文介绍了一种解决Java中因jar包冲突导致类冲突的方法,通过输出特定类所在的jar包路径来定位问题源头。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  这次遇到的问题仍然是jar包冲突遇到的问题,导致jar包里的类冲突以至于方法报错,java.lang.NoSuchMethodError.

解决办法也开始逐个排查jar包,反编译jar包里的内容和其他的jar包比对.这是眼都花了.如果有maven就没这么多事了,但是

又是个线上的项目,迁移到maven不能保证不会出什么幺蛾子,就只能将就这,就只能将就者逐渐的迁移.

  后来想java里有输出该类所在所在jar包路径的方法.

String className = request.getParameter("className");  
PrintWriter printWriter = new PrintWriter(response.getWriter());  
if(className == null || className.isEmpty()){  
    printWriter.write("className shoud be specified");  
}else{  
    Class<?> clazz = null;  
    try{  
        clazz = Class.forName(className);  
    }catch(Exception e){  
          
    }  
    if(clazz == null){  
        printWriter.println(className + "not found");  
    }else{  
        CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();  
        if(codeSource == null){  
            printWriter.println(className + " location not available");  
        }else{  
            String location = codeSource.getLocation().getPath();  
            printWriter.println(className + " location: " + location);  
        }  
    }  
}  
printWriter.flush();  

这是核心的代码,本来打算写个action,看到网上有将其写到jsp里的更方便.

 

转载于:https://www.cnblogs.com/wufy/p/6530614.html

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.5.4</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.mz</groupId> <artifactId>hejiayun-community</artifactId> <version>0.0.1-SNAPSHOT</version> <name>hejiayun-community</name> <packaging>jar</packaging> <description>合家云社区物业管理平台</description> <properties> <java.version>17</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> <druid.version>1.2.21</druid.version> <bitwalker.version>1.21</bitwalker.version> <fastjson.version>2.0.43</fastjson.version> <oshi.version>6.4.6</oshi.version> <jna.version>5.13.0</jna.version> <commons.fileupload.version>1.5</commons.fileupload.version> <poi.version>5.2.4</poi.version> <velocity.version>2.3</velocity.version> <jwt.version>0.12.3</jwt.version> <mybatis-plus.version>3.5.5</mybatis-plus.version> <easy-captcha.version>1.6.2</easy-captcha.version> <jsqlparser.version>4.5</jsqlparser.version> </properties> <dependencies> <!-- Spring Boot Web Starter --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Spring Boot AOP --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!-- Spring Boot Validation --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <!-- Spring Boot DevTools --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <!-- MySQL Connector --> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> </dependency> <!-- Druid Connection Pool --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-3-starter</artifactId> <version>${druid.version}</version> </dependency> <!-- MyBatis Plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus.version}</version> </dependency> <!-- <!– PageHelper –> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.4.7</version> </dependency>--> <!-- Redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency> <!-- FastJSON2 (替代FastJSON) --> <dependency> <groupId>com.alibaba.fastjson2</groupId> <artifactId>fastjson2</artifactId> <version>${fastjson.version}</version> </dependency> <!-- Jackson for JSON processing --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <!-- JWT Token --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>${jwt.version}</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>${jwt.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <version>${jwt.version}</version> <scope>runtime</scope> </dependency> <!-- System Information --> <dependency> <groupId>com.github.oshi</groupId> <artifactId>oshi-core</artifactId> <version>${oshi.version}</version> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>${jna.version}</version> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna-platform</artifactId> <version>${jna.version}</version> </dependency> <!-- User Agent Utils --> <dependency> <groupId>eu.bitwalker</groupId> <artifactId>UserAgentUtils</artifactId> <version>${bitwalker.version}</version> </dependency> <!-- Captcha --> <dependency> <groupId>com.github.whvcse</groupId> <artifactId>easy-captcha</artifactId> <version>${easy-captcha.version}</version> </dependency> <!-- Spring Boot Logging --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency> <!-- Test Dependencies --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <!-- Spring Security (如果需要,取消注释) --> <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> --> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>17</source> <target>17</target> </configuration> </plugin> </plugins> </build> </project>看看我的配置文件
最新发布
07-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值