Maven“在Linux上找不到符号”错误,但不是Windows

我的问题类似于:

maven compilation failure

但没有解决方案有效.

我有两个maven项目:A是B的依赖项.我可以在Windows 7(我的开发机器)和Linux(AWS EC2实例)上成功编译,测试,打包和安装A.我还可以在Windows 7上编译,测试,打包和安装B.但是当我尝试在Linux上编译B时,maven会出现“找不到符号”错误:

    # 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依赖项:列表显示没有警告. Project A 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>

非常感谢任何帮助.

最佳答案 经过进一步研究,结果证明这根本不是一个maven问题.某些文件具有不正确的UNIX权限,这会以某种方式导致误导性错误.在确保所有工作目录已被chown’d并正确chmod之后,构建工作正常.

点赞