一片月 2024-06-13 21:37 采纳率: 0%
浏览 11
已结题

sqpingboot在父模块已经引入了mybatisplus 在子组件不写版本号还是报错

sqpingboot在父模块已经引入了mybatisplus 在子组件不写版本号还是报错
报错提示

"D:\Program Files\Java\jdk-1.8\bin\java.exe" -Dmaven.multiModuleProjectDirectory=D:\react\programming-guide-server -Dmaven.home=D:\apache-maven-3.6.3 -Dclassworlds.conf=D:\apache-maven-3.6.3\bin\m2.conf "-Dmaven.ext.class.path=D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.4\plugins\maven\lib\maven-event-listener.jar" "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.4\lib\idea_rt.jar=53775:D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.4\bin" -Dfile.encoding=UTF-8 -classpath D:\apache-maven-3.6.3\boot\plexus-classworlds-2.6.0.jar;D:\apache-maven-3.6.3\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version=2022.1.4 -s D:\apache-maven-3.6.3\conf\settings.xml org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for com.baomidou:mybatis-plus-annotation:jar is missing. @ line 27, column 21
[WARNING] 'dependencies.dependency.scope' for com.alibaba.cloud:spring-cloud-alibaba-dependencies:pom must be one of [provided, compile, runtime, test, system] but is 'import'. @ line 19, column 20
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.example:code-pojo:1.0-SNAPSHOT (D:\react\programming-guide-server\code-pojo\pom.xml) has 1 error
[ERROR]     'dependencies.dependency.version' for com.baomidou:mybatis-plus-annotation:jar is missing. @ line 27, column 21
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

Process finished with exit code 1


父模块POM代码


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.7.3</version>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>code-guide</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>code-common</module>
        <module>code-pojo</module>
        <module>code-service</module>
    </modules>
    <properties>
        <mybatis-plus.version>3.4.3</mybatis-plus.version>
        <lombok>1.18.20</lombok>
        <fastjson>1.2.76</fastjson>
        <commons.lang>2.6</commons.lang>
        <druid>1.2.1</druid>
        <pagehelper>1.3.0</pagehelper>
        <aliyun.sdk.oss>3.10.2</aliyun.sdk.oss>
        <knife4j>3.0.2</knife4j>
        <aspectj>1.9.4</aspectj>
        <jjwt>0.9.1</jjwt>
        <jaxb-api>2.3.1</jaxb-api>
        <poi>3.16</poi>
        <hutool.version>5.8.0</hutool.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>cn.hutool</groupId>
                <artifactId>hutool-bom</artifactId>
                <version>${hutool.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok}</version>
            </dependency>

            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson}</version>
            </dependency>

            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>${commons.lang}</version>
            </dependency>

            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid-spring-boot-starter</artifactId>
                <version>${druid}</version>
            </dependency>

            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>${pagehelper}</version>
            </dependency>

            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>knife4j-spring-boot-starter</artifactId>
                <version>${knife4j}</version>
            </dependency>

            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>${aspectj}</version>
            </dependency>

            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>${aspectj}</version>
            </dependency>

            <dependency>
                <groupId>io.jsonwebtoken</groupId>
                <artifactId>jjwt</artifactId>
                <version>${jjwt}</version>
            </dependency>

            <dependency>
                <groupId>com.aliyun.oss</groupId>
                <artifactId>aliyun-sdk-oss</artifactId>
                <version>${aliyun.sdk.oss}</version>
            </dependency>

            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>${jaxb-api}</version>
            </dependency>

            <!-- poi -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>${poi}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>${poi}</version>
            </dependency>
            <!--微信支付-->
            <dependency>
                <groupId>com.github.wechatpay-apiv3</groupId>
                <artifactId>wechatpay-apache-httpclient</artifactId>
                <version>0.4.8</version>
            </dependency>

            <!-- springboot 邮件mail -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-mail</artifactId>
                <version>2.4.5</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>


子模块POM代码

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>code-guide</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>code-service</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-dependencies</artifactId>
            <version>2022.0.0.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>code-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>code-pojo</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>8.0.33</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>app</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>


  • 写回答

10条回答 默认 最新

  • 妄北y 嵌入式领域优质创作者 2024-06-13 21:38
    关注

    以下参考免费微信小程序:皆我百晓生 作答,并由妄北y整理回复。

    根据你提供的错误信息和POM文件,问题出在子模块的pom.xml中,MyBatis-Plus的依赖没有指定版本号。虽然你在父模块中已经定义了MyBatis-Plus的版本号,但是子模块并没有正确地继承这个版本号。解决这个问题的方法如下:

    1. 在子模块的pom.xml中显式引入MyBatis-Plus的版本号:你需要在子模块的pom.xml中为MyBatis-Plus的依赖指定版本号,就像你在父模块中所做的那样。这样可以确保Maven知道使用哪个版本。

      <dependency>
          <groupId>com.baomidou</groupId>
          <artifactId>mybatis-plus-boot-starter</artifactId>
          <version>${mybatis-plus.version}</version>
      </dependency>
      
    2. 确保子模块正确地继承了父模块的属性:在子模块的pom.xml中,确保你引入了父模块的属性。你可以在子模块的pom.xml中添加一个<properties>标签来引用父模块中的属性。

      <properties>
          <mybatis-plus.version>${project.parent.version}</mybatis-plus.version>
          <!-- 其他属性 -->
      </properties>
      

      注意:这里假设你的父模块版本号是作为一个属性定义的,如果不是,你需要相应地调整引用。

    3. 清理和更新项目:在IDEA中,你可以尝试清理Maven项目和更新项目依赖。这可以通过点击IDEA底部右侧的Maven工具窗口中的“刷新”按钮来完成。

    4. 检查是否有其他依赖冲突:有时候,依赖问题可能是由于其他依赖的版本冲突引起的。使用Maven的依赖树功能(mvn dependency:tree)来检查是否有依赖冲突,并相应地调整版本号。

    5. 检查父模块的pom.xml:确保父模块的pom.xml没有语法错误,并且确实定义了MyBatis-Plus的版本号。

    6. 重新构建项目:在解决了上述问题之后,重新构建你的项目,看看是否还有错误。

    如果以上步骤都无法解决问题,你可能需要检查IDEA的Maven配置,或者尝试在命令行中运行Maven命令,以确定问题是否与IDEA的集成有关。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 6月14日
  • 创建了问题 6月13日

悬赏问题

  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥20 双系统开机引导中windows系统消失问题?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方
  • ¥15 关于生产日期批次退货退款,库存回退的问题