boomslap 5 Share Posted December 18, 2021 I would like to use the StringUtils class from the apache.commons.lang3 package on my script. I have added it as a dependency on my maven pom file but since the same package exists inside the client.jar, it gets priority during runtime and I get a 'NoSuchMethodError' when executing for instance the StringUtils.capitalize(String) method because that method doesn't exist in the version included in the client.jar. Is there a workaround this to give priority to my dependency over the package included in the client.jar? Could you possibly include the entire library inside the client.jar? Thanks! Link to comment Share on other sites More sharing options...
Axolotl 31 Share Posted December 18, 2021 5 hours ago, boomslap said: I would like to use the StringUtils class from the apache.commons.lang3 package on my script. I have added it as a dependency on my maven pom file but since the same package exists inside the client.jar, it gets priority during runtime and I get a 'NoSuchMethodError' when executing for instance the StringUtils.capitalize(String) method because that method doesn't exist in the version included in the client.jar. Is there a workaround this to give priority to my dependency over the package included in the client.jar? Could you possibly include the entire library inside the client.jar? Thanks! Not too sure on the overall answer with dependancy priority when it comes to naming conflicts, but when it comes to StringUtils.capitalize heres my GUI failsafe you can use: private static String itemNameFormatting(String itemName) { StringBuilder formatted = new StringBuilder(); String lower = itemName.toLowerCase(); boolean upperCase = true; for(int i = 0; i < lower.length(); i++) { char letter = lower.charAt(i); if(upperCase) { String upper = "" + letter; formatted.append(upper.toUpperCase()); upperCase = false; } else formatted.append(letter); } MethodProvider.log("Formatted itemName: " + itemName + " to: " + formatted); return formatted.toString(); } Link to comment Share on other sites More sharing options...
boomslap 5 Author Share Posted December 18, 2021 4 hours ago, Axolotl said: Not too sure on the overall answer with dependancy priority when it comes to naming conflicts, but when it comes to StringUtils.capitalize heres my GUI failsafe you can use: private static String itemNameFormatting(String itemName) { StringBuilder formatted = new StringBuilder(); String lower = itemName.toLowerCase(); boolean upperCase = true; for(int i = 0; i < lower.length(); i++) { char letter = lower.charAt(i); if(upperCase) { String upper = "" + letter; formatted.append(upper.toUpperCase()); upperCase = false; } else formatted.append(letter); } MethodProvider.log("Formatted itemName: " + itemName + " to: " + formatted); return formatted.toString(); } Thanks a lot for the suggestion and the code! Recreating the functions I need is something I thought of doing but I would want to avoid it if possible since this is an issue where similar conflicts can happen with other dependencies and they are quite annoying to find and fix. Link to comment Share on other sites More sharing options...
NotAnyChef 0 Share Posted December 24, 2021 I'm in the same boat Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.