te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>maven spring boot dependency version override - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

maven spring boot dependency version override - Stack Overflow

programmeradmin3浏览0评论

Due to a CVE I need to update the version of netty in one of my builds.

In my POM I believed I could override the property like this:

    <properties>
        <netty.version>4.1.118.Final</netty.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>3.4.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

but looking at the dependency tree using mvn -U -Dverbose dependency:tree I'm seeing the version is still 117. I assume this is because some other dependency management section in my dependencies is defining the version as 4.1.117.FINAL

Is there a way to ask maven WHAT POM is version managing this?

The tree reports:

+- (ioty:netty-common:jar:4.1.117.Final:compile - version managed from 4.1.117.Final; omitted for duplicate)

mvn version:

$ mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: ~/.sdkman/candidates/maven/current
Java version: 21.0.3, vendor: Oracle Corporation, runtime: ~/.sdkman/candidates/java/21.0.3-graal
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-53-generic", arch: "amd64", family: "unix"

Due to a CVE I need to update the version of netty in one of my builds.

In my POM I believed I could override the property like this:

    <properties>
        <netty.version>4.1.118.Final</netty.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>3.4.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

but looking at the dependency tree using mvn -U -Dverbose dependency:tree I'm seeing the version is still 117. I assume this is because some other dependency management section in my dependencies is defining the version as 4.1.117.FINAL

Is there a way to ask maven WHAT POM is version managing this?

The tree reports:

+- (ioty:netty-common:jar:4.1.117.Final:compile - version managed from 4.1.117.Final; omitted for duplicate)

mvn version:

$ mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: ~/.sdkman/candidates/maven/current
Java version: 21.0.3, vendor: Oracle Corporation, runtime: ~/.sdkman/candidates/java/21.0.3-graal
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-53-generic", arch: "amd64", family: "unix"
Share Improve this question edited Feb 18 at 8:29 theINtoy asked Feb 17 at 18:37 theINtoytheINtoy 3,6982 gold badges40 silver badges65 bronze badges 3
  • 1 overriding using property only works if you use spring-boot starter parent. In your case, you need to put netty dependency before the spring-boot-dependencies dependency. <dependency> <groupId>ioty</groupId> <artifactId>netty-all</artifactId> <version>4.1.118.Final</version> </dependency> – Hendra Commented Feb 17 at 22:33
  • Thanks for the reply. This approach does not work. I assume becuase the version of netty is being managed somewhere from a dependencyManagement section in a dependent BOM. Adding the above artefact into both depenancyManagement achieves the same as the tree above, Adding to dependencies gives: +- ioty:netty-all:jar:4.1.118.Final:compile [INFO] | +- ioty:netty-buffer:jar:4.1.117.Final:compile (version managed from 4.1.118.Final; scope not updated to compile) – theINtoy Commented Feb 18 at 8:33
  • mvn help:effective-pom may give more insight – Hendra Commented 2 days ago
Add a comment  | 

1 Answer 1

Reset to default 2

If the same artifact is defined with different versions in 2 imported BOMs, then the version in the BOM file that was declared first will win.

You need to add the netty dependency like this.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>ioty</groupId>
            <artifactId>netty-bom</artifactId>
            <version>4.1.118.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>3.4.2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

BOMs are imported into the section and only provide version numbers and scopes for dependencies that are used elsewhere. They are not “real” dependencies; they do not appear in the dependency tree as distinct nodes. This means Maven doesn’t show “this version was set by spring-boot-dependencies” explicitly. Tools like dependency:tree or help:effective-pom show the end result of dependency management but do not annotate the source BOM once the version is resolved.

发布评论

评论列表(0)

  1. 暂无评论