执行Maven clean install遇依赖解析失败,无法从search.maven.org下载构件
Let’s work through this dependency problem you’re facing when running mvn clean install on the clusterInfinispan module. Here’s what’s happening and how to fix it:
Core Issue Breakdown
The root cause is that Maven can’t locate the org.jberet:jberet-wildfly:pom:1.4.0.Alpha-SNAPSHOT artifact. While release versions of JBeret components live on Maven Central (which is why you found related artifacts on search.maven.org), SNAPSHOT versions like this aren’t hosted in Central. They’re typically stored in vendor or project-specific snapshot repositories—for JBeret, that’s JBoss’s snapshot repo.
Maven only checks repositories you explicitly configure (by default, just Maven Central), so it had no way to find this snapshot artifact automatically. That’s why running mvn -U clean install or clearing your local repo didn’t help—Maven wasn’t looking in the right place at all.
Step-by-Step Fix
You’ll need to add the JBoss Snapshot Repository to either your project’s pom.xml (for project-specific access) or your global Maven settings.xml (to apply it to all your Maven projects).
Option 1: Add to the Project’s pom.xml
Open the pom.xml of the clusterInfinispan module (or the parent pom of the jberet-wildfly-samples project) and insert this repository configuration:
<repositories> <repository> <id>jboss-snapshots</id> <name>JBoss Snapshot Repository</name> <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url> <releases> <enabled>false</enabled> <!-- Skip release artifacts here --> </releases> <snapshots> <enabled>true</enabled> <!-- Allow snapshot artifacts --> <updatePolicy>always</updatePolicy> <!-- Force Maven to check for updates --> </snapshots> </repository> </repositories>
Option 2: Add to Global Maven settings.xml
If you want this repository available for all your Maven projects, edit your settings.xml (usually located at ~/.m2/settings.xml on Unix-like systems or C:\Users\{YourUsername}\.m2\settings.xml on Windows) and add the repository inside the <profiles> section:
<profile> <id>jboss-snapshots</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>jboss-snapshots</id> <name>JBoss Snapshot Repository</name> <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile>
Verify the Fix
After adding the repository, run mvn -U clean install again. The -U flag will force Maven to pull the latest snapshot dependencies from the new repository, and it should now resolve the missing jberet-wildfly:pom:1.4.0.Alpha-SNAPSHOT artifact successfully.
内容的提问来源于stack exchange,提问作者Fabrizio Stellato

