鍍金池/ 問答/Java  網(wǎng)絡(luò)安全/ maven compilation failure

maven compilation failure

一、maven編譯spring boot工程找不到程序包

1.A、B兩個工程
2.B工程依賴于A工程[A打成jar包]
maven編譯B工程期間報 程序包*不存在

com/ebtce/open/inner/logistic/service/LogisticSubscribeAPI.java:[3,51] 程序包c(diǎn)om.ebtce.open.common.service.logs.impl不存在
com/ebtce/open/inner/logistic/service/LogisticSubscribeAPI.java:[4,38] 程序包c(diǎn)om.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包相關(guān)代碼正常包含]

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

圖片描述

三、pom相關(guān)配置

<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>

依賴正常
圖片描述

回答
編輯回答
野橘

一、分析
找不到包應(yīng)該為路徑問題,項(xiàng)目能正常啟動,maven編譯不過,猜測所打jar包出現(xiàn)的問題

二、原因
參考:maven mulit-module dependency package not found
問題出現(xiàn)在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

2017年1月6日 01:22