Maven试图使用/var/empty/.m2/repository作为我的本地存储库

时间:2014-03-12 21:16:30

标签: maven maven-3

这刚刚开始。直到今天下午,我已经能够在我的项目目录中运行mvn clean install而没有任何问题。我今天下午试图这样做,并得到以下错误:

MusikPolice$ mvn -X clean install
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 11:22:22-0400)
Maven home: /Applications/apache-maven-3.1.1
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.1", arch: "x86_64", family: "mac"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /Applications/apache-maven-3.1.1/conf/settings.xml
[DEBUG] Reading user settings from /var/empty/.m2/settings.xml
[DEBUG] Using local repository at /var/empty/.m2/repository
[ERROR] Could not create local repository at /var/empty/.m2/repository -> [Help 1]
org.apache.maven.repository.LocalRepositoryNotAccessibleException: Could not create local repository at /var/empty/.m2/repository
    at org.apache.maven.DefaultMaven.validateLocalRepository(DefaultMaven.java:505)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:191)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LocalRepositoryNotAccessibleException

它建议我阅读的维基页面并不十分有用,只是暗示如果Maven无法写入~/.m2/repository/目录,可能会发生这种情况。

还有其他想法吗?

1 个答案:

答案 0 :(得分:4)

由于此日志消息:

[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /Applications/apache-maven-3.1.1/conf/settings.xml
[DEBUG] Reading user settings from /var/empty/.m2/settings.xml

似乎Maven之后有红色/Applications/apache-maven-3.1.1/conf/settings.xml开始阅读/var/empty/.m2/settings.xml,因此如果以下行已取消注释,请检查/Applications/apache-maven-3.1.1/conf/settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

并将localRepository设置为/var/empty/