Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven classpath order between dependency jars and src/main/resources?

Tags:

maven

I'm trying to run mvn exec:java .....

then it uses the runtime classpath defined by my pom, which I think defaults to the compile classpath. the problem is that I found that my src/main/resources/log4j.xml is not reflected, since I put DEBUG logging in the file, but I only see WARN in the output. I suspect that it's actually the log4j.xml from some of the dependency jars that is being used. so I need to elevate the src/main/resources/log4j.xml to the front of my compile/runtime classpath. but how do I specify the relative order of src/main/resources vs dependency jars in the classpath?

Thanks Yang

like image 307
teddy teddy Avatar asked Sep 04 '26 08:09

teddy teddy


1 Answers

One workaround is to explicitly specify the log4j.xml that you want log4j to use using a command-line argument.

-Dlog4j.configuration=file:/log4j.xml
like image 118
Raghuram Avatar answered Sep 08 '26 19:09

Raghuram