我的問題類似於: maven compilation failure 但是沒有解決方法。Maven在Linux上找不到符號錯誤但不是Windows
我有兩個maven項目:A是B的依賴關係。我可以在Windows 7(我的開發機器)和Linux(AWS EC2實例)上成功編譯,測試,打包和安裝A.我也可以編譯,測試,封裝,並在Windows 7安裝B當我嘗試編譯B於Linux的,然而,行家提出了一個「無法找到符號」錯誤:
# mvn clean package install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxxxx-api Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ xxxxx-api ---
[INFO] Deleting /secure-mnt/xxxxx-api/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ xxxxx-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ xxxxx-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 20 source files to /secure-mnt/xxxxx-api/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /secure-mnt/xxxxx-api/src/main/java/com/company/util/Logging.java:[21,13] cannot find symbol
symbol: class CryptoLogging
[ERROR] /secure-mnt/xxxxx-api/src/main/java/com/company/util/Logging.java:[32,39] cannot find symbol
symbol: method getLogger(java.lang.String)
location: class com.company.util.Logging
[INFO] 2 errors
.....
我對Java的相同版本(1.7.0_25)和Maven(3.0.5)安裝在兩個系統上,並且兩者都使用來自Git的相同源代碼版本。運行mvn dependency:list
顯示沒有警告。項目一個jar在Linux服務器的本地m2存儲庫中,並且具有可用的類和方法。
似乎Maven並沒有讓Java編譯器意識到Linux上的Project A jar,但我不明白爲什麼。 Maven可能無法正確指定Java類路徑嗎?
有沒有人有建議嘗試或測試的東西?
如果它是相關的:
# mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
Maven home: /usr/local/apache-maven/apache-maven-3.0.5
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_25/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.4.48-45.46.amzn1.x86_64", arch: "i386", family: "unix"
因爲我相信有人會問看POM,這裏是B項目的相關部分有什麼特別的依賴都:
<dependencies>
<!-- For Project A. -->
<dependency>
<groupId>com.company.projectA</groupId>
<artifactId>company-projectA</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- For RESTful services. -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
<!-- For testing. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
非常感謝您的幫助。
即使我明確地將存儲庫設置爲默認存儲庫('export M2_REPO =〜/ .m2/repository')並以'mvn -o clean package install'離線模式運行,這種情況仍然會失敗。軟件包A安裝到本地存儲庫,但軟件包B找不到它。 – Richard