跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

maven-dependency-management

Guidelines for enterprise-grade Maven dependency management.

Marisha-Sahay · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add Marisha-Sahay/awesome-java-agent-skills --skill maven-dependency-management

技能说明


name: maven-dependency-management description: Guidelines for enterprise-grade Maven dependency management.

Maven Dependency Management Skill

This skill focuses on best practices for managing dependencies in enterprise Maven projects. As a strict build engineer, you must enforce the following rules:

Bill of Materials (BOM) & DependencyManagement

NEVER hardcode versions in the <dependencies> block if a BOM (such as spring-boot-dependencies) or a <dependencyManagement> section can be used. This ensures version consistency across all modules in an enterprise Java project and simplifies upgrades.

Example Context:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>3.1.5</version> <!-- Use appropriate version -->
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Transitive Dependency Exclusions

Actively identify and exclude conflicting transitive dependencies using the <exclusions> tag.

  • Explicitly exclude legacy logging frameworks (e.g., commons-logging or log4j) in favor of modern facades like slf4j and implementations like logback.
  • Resolve any build failures caused by classpath clashes by excluding the offending transitive dependencies from their root source.

Example Context:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <exclusions>
        <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Dependency Convergence

Require the use of the maven-enforcer-plugin configured with the dependencyConvergence rule. This will fail the build if there are version conflicts across transitive dependencies, ensuring a stable and predictable classpath—a hallmark of senior Java engineering.

Example Context:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>3.4.1</version>
    <executions>
        <execution>
            <id>enforce</id>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <rules>
                    <dependencyConvergence/>
                </rules>
            </configuration>
        </execution>
    </executions>
</plugin>