Heroku部署Java Selenium爬虫时Maven依赖插件找不到的问题
Hey there! Let's walk through why you're hitting this error even though the plugin exists on Maven Repository, and how to fix it step by step.
Common Causes & Fixes
1. Corrupted or Missing Local Maven Cache
Maven stores downloaded plugins in your local .m2 repository, and sometimes the cache gets corrupted or fails to download the plugin properly. Here's how to fix it:
- Navigate to your local Maven repository (usually
~/.m2/repository/org/apache/maven/plugins/maven-dependency-plugin/on Unix-like systems, orC:\Users\<YourUsername>\.m2\repository\org\apache\maven\plugins\maven-dependency-plugin\on Windows). - Delete the
3.0.1folder entirely. - Run
mvn clean packageagain locally—this will force Maven to re-download the plugin from scratch.
2. Maven Mirror Sync Issues
If you're using a custom Maven mirror (like a domestic mirror for faster access), it might not have synced the 3.0.1 version of the plugin yet. Try these steps:
- Check your
settings.xmlfile (located in~/.m2/or your Maven installation directory) for mirror configurations. - Temporarily comment out any custom mirrors and use the official Maven Central Repository directly.
- Re-run your build to see if the plugin downloads successfully. If it does, you can either stick with the official repo or wait for your mirror to sync the version.
3. Outdated Plugin Version Compatibility
Version 3.0.1 of the maven-dependency-plugin is pretty old (released back in 2017), and it might not play nicely with newer versions of Maven (3.8.x and above). A quick fix here is to upgrade to a newer stable version:
- Replace the version in your pom.xml with the latest stable release (as of now, that's 3.6.1):
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.6.1</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals><goal>copy-dependencies</goal></goals> </execution> </executions> </plugin> - Run
mvn clean packageagain—newer versions are more likely to be compatible with modern Maven setups and Heroku's environment.
4. Heroku-Specific Repository Configuration
Heroku's Maven environment might be using a different repository setup than your local machine. To force Heroku to pull from Maven Central explicitly, add these repository configurations to your pom.xml:
<repositories> <repository> <id>central</id> <url>https://repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>https://repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories>
This ensures Heroku doesn't rely on any default mirrors that might be missing the plugin version.
Quick Testing Tip
If you want to debug the issue directly on Heroku, run this command to get verbose dependency logs:
heroku run mvn dependency:tree -Dverbose
This will show you exactly where Maven is trying to pull plugins from, which can help pinpoint the root cause.
内容的提问来源于stack exchange,提问作者Mate Mrše

