maven compilation failure

发布于 2022-09-06 08:22:14 字数 1759 浏览 11 评论 0

一、maven编译spring boot工程找不到程序包

1.A、B两个工程
2.B工程依赖于A工程[A打成jar包]
maven编译B工程期间报 程序包*不存在

com/ebtce/open/inner/logistic/service/LogisticSubscribeAPI.java:[3,51] 程序包com.ebtce.open.common.service.logs.impl不存在
com/ebtce/open/inner/logistic/service/LogisticSubscribeAPI.java:[4,38] 程序包com.ebtce.open.common.util不存在

二、说明

1.maven 编译jdk版本与工程保持一致(jdk1.8)

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Java version: 1.8.0_101, vendor: Oracle Corporation

2.A工程JAR包正常引入[A JAR包正常安装到本地库中,反编译jar包相关代码正常包含]

[DEBUG]    com.ebtce.open.common:ebtce-service-open-common:jar:1.1:compile

图片描述

三、pom相关配置

<dependency>
    <groupId>com.ebtce.open.common</groupId>
    <artifactId>ebtce-service-open-common</artifactId>
    <version>1.1</version>
</dependency>
    
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

依赖正常
图片描述

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帥小哥 2022-09-13 08:22:14

一、分析
找不到包应该为路径问题,项目能正常启动,maven编译不过,猜测所打jar包出现的问题

二、原因
参考:maven mulit-module dependency package not found
问题出现在maven spring boot打包插件上
1.spring boot packaging plugin

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

打包后所有的包和类都放到了BOOT-INF文件夹中

图片描述

2.maven packaging plugin

build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>
    </plugins>
</build>

包在根路径下

图片描述

三、解决方案

替换build插件为maven打包插件即可

其它原因参考maven compilation failure

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文