麻烦用Maven编译

时间:2013-07-22 19:19:25

标签: java maven

我的Maven安装最近开始花费很长时间来编译项目。使用单个源文件的项目在我的系统上编译需要将近4分钟,之前我能够在不到两分钟的时间内构建包含100多个源文件的项目。我不知道我做了什么导致这个问题。到目前为止我唯一的理论是它涉及Maven似乎在构建过程中使用的local.repository目录,因为我错误地删除了这个文件夹(?),因为它看起来很空无用。

到目前为止,我尝试解决此问题包括将我的Maven构建升级到3.1,重新启动我的计算机,删除maven缓存`(~/.m2/)并增加Maven可用的内存量,如here中所述

我的构建的输出:

    [INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-app ---
[INFO] Deleting /Users/alexwood/Software_Development/Projects/Maven Tutorial/my-app/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/alexwood/Software_Development/Projects/Maven Tutorial/my-app/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ my-app ---
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/alexwood/Software_Development/Projects/Maven Tutorial/my-app/target/classes

My Maven版本信息:

Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 19:15:32-0700)
Maven home: /usr/local/Cellar/maven/3.1.0/libexec
Java version: 1.6.0_51, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

我正在使用的pom.xml文件:

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
  </dependency>
</dependencies>

非常感谢任何帮助。如果我可以提供任何进一步的说明,请告诉我。

1 个答案:

答案 0 :(得分:2)

问题最终与JDK有关。为我的系统重新安装最新的Java版本解决了这个问题。