spring-boot-starter-web 必须指定 version?

2021-07-02 15:15:33 +08:00
 asanelder

是一个多模块 maven 项目

父项目的 pom.xml 如下

<groupId>org.example</groupId>
<artifactId>parent</artifactId>
 <version>1.0-SNAPSHOT</version>

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.5</version>
</parent>

<modules>
    <module>submodule</module>
</modules>

子项目 pom.xml

    <parent>
        <artifactId>parent</artifactId>
        <groupId>org.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>submodule</artifactId>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

    </dependencies>

现在 mvn compile 报错, 说 spring-boot-starter-web 没有指定 version, 但 spring-boot-starter-actuator 却没有问题.

有铁子知道原因么?

PS: 结贴, 找到原因了...

1765 次点击
所在节点    程序员
6 条回复
iddddg
2021-07-02 17:20:20 +08:00
想知道啥原因
qwerthhusn
2021-07-02 17:24:34 +08:00
终贴,你起码把原因说一下啊?!!
起码后面其他人万一碰到了,也能有类似的解决经验
starxg
2021-07-02 19:06:25 +08:00
或许还没轮到 spring-boot-starter-actuator
lonenol
2021-07-02 19:11:15 +08:00
@qwerthhusn 肯定在子目录里执行 mvn compile 了呗
JasonLaw
2021-07-03 08:22:33 +08:00
自己提出一个问题,然后说已经解决了,又不说是怎么解决的。唉🤕
asanelder
2021-07-03 09:49:16 +08:00
@iddddg #1
@qwerthhusn #2
@starxg #3
@lonenol #4
@JasonLaw #5 哈哈, 不好意思, 铁子们

原因是俺大意了啊~~~~

其实是在父 pom 中, 不小心声明了

<dependencyManagement>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

</dependencies>
</dependencyManagement>


所以, 在 submodule 就说 version 没有指定, 而 spring-boot-starter-actuator 并没有声明...

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/787153

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX