2016-03-15 102 views
0

我想運行官方Java EE 7教程代碼示例並獲取錯誤。我已經在這裏閱讀了它,大部分結果表明你必須檢查你的Maven插件目標是否與你的系統JDK環境變量相同。我JDK_HOME是:Maven致命錯誤編譯:找不到目錄:maven-compiler-plugin

jdk home image

這是我父母的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/xsd/maven-4.0.0.xsd"> 
 
    <modelVersion>4.0.0</modelVersion> 
 
    <groupId>org.glassfish.javaeetutorial</groupId> 
 
    <artifactId>javaeetutorial</artifactId> 
 
    <version>7.0.5</version> 
 
    <packaging>pom</packaging> 
 
    <name>javaeetutorial</name> 
 
    
 
    <scm> 
 
     <connection>scm:svn:https://svn.java.net/svn/javaeetutorial~svn/tags/javaeetutorial-7.0.0</connection> 
 
     <developerConnection>scm:svn:https://svn.java.net/svn/javaeetutorial~svn/tags/javaeetutorial-7.0.0</developerConnection> 
 
    </scm> 
 
    <issueManagement> 
 
     <system>IssueTracker</system> 
 
     <url>http://java.net/jira/browse/JAVAEETUTORIAL</url> 
 
    </issueManagement> 
 
    
 
    <properties> 
 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
 
     <javaee.api.version>7.0</javaee.api.version> 
 
     <maven.compiler.plugin.version>3.2</maven.compiler.plugin.version> 
 
     <maven.source.plugin.version>2.2.1</maven.source.plugin.version> 
 
     <maven.clean.plugin.version>2.5</maven.clean.plugin.version> 
 
     <maven.war.plugin.version>2.3</maven.war.plugin.version> 
 
     <maven.acr.plugin.version>1.0</maven.acr.plugin.version> 
 
     <maven.ear.plugin.version>2.8</maven.ear.plugin.version> 
 
     <maven.ejb.plugin.version>2.3</maven.ejb.plugin.version> 
 
     <maven.jar.plugin.version>2.4</maven.jar.plugin.version> 
 
     <maven.rar.plugin.version>2.3</maven.rar.plugin.version> 
 
     <maven.license.plugin.version>1.10.b1</maven.license.plugin.version> 
 
     <maven.release.plugin.version>2.4.1</maven.release.plugin.version> 
 
     <maven.exec.plugin.version>1.2.1</maven.exec.plugin.version> 
 
     <junit.version>4.11</junit.version> 
 
     <eclipselink.version>2.5.0</eclipselink.version> 
 
     <glassfish.embedded.version>4.0</glassfish.embedded.version> 
 
     <cargo.plugin.version>1.4.4</cargo.plugin.version> 
 
     <glassfish.domain.name>domain1</glassfish.domain.name> 
 
     <glassfish.home>${glassfish.home.prefix}/glassfish4</glassfish.home> 
 
     <integration.container.id>glassfish4x</integration.container.id> 
 
    </properties> 
 
    
 
    <profiles> 
 
     <profile> 
 
      <id>windows</id> 
 
      <activation> 
 
       <os> 
 
        <family>windows</family> 
 
       </os> 
 
      </activation> 
 
      <properties> 
 
       <glassfish.home.prefix>c:/</glassfish.home.prefix> 
 
       <glassfish.executables.suffix>.bat</glassfish.executables.suffix> 
 
      </properties> 
 
     </profile> 
 
     <profile> 
 
      <id>unix</id> 
 
      <activation> 
 
       <os> 
 
        <family>unix</family> 
 
       </os> 
 
      </activation> 
 
      <properties> 
 
       <glassfish.home.prefix>${user.home}</glassfish.home.prefix> 
 
       <glassfish.executables.suffix /> 
 
      </properties> 
 
     </profile> 
 
     <profile> 
 
      <id>sdk</id> 
 
      <activation> 
 
       <activeByDefault>true</activeByDefault> 
 
      </activation> 
 
      <properties> 
 
       <glassfish.home>${basedir}/../../../</glassfish.home> 
 
      </properties> 
 
     </profile> 
 
     <profile> 
 
      <id>development</id> 
 
      <activation> 
 
       <file> 
 
        <exists>${basedir}/../bundle</exists> 
 
       </file> 
 
      </activation> 
 
      <properties> 
 
       <glassfish.home>${glassfish.home.prefix}/glassfish4</glassfish.home> 
 
      </properties> 
 
     </profile> 
 
     <profile> 
 
      <id>standalone</id> 
 
      <properties> 
 
       <glassfish.home>${basedir}/target/cargo/installs/glassfish</glassfish.home> 
 
       <cargo.maven.containerUrl>http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip</cargo.maven.containerUrl> 
 
      </properties> 
 
     </profile> 
 
    </profiles> 
 
    
 
    <modules> 
 
     <module>archetypes</module> 
 
     <module>batch</module> 
 
     <module>case-studies</module> 
 
     <module>cdi</module> 
 
     <module>concurrency</module> 
 
     <module>connectors</module> 
 
     <module>ejb</module> 
 
     <module>jaxrs</module> 
 
     <module>jaxws</module> 
 
     <module>jms</module> 
 
     <module>persistence</module> 
 
     <module>security</module> 
 
     <module>web</module> 
 
    </modules> 
 
    
 
    <repositories> 
 
     <repository> 
 
      <id>snapshot-repository.java.net</id> 
 
      <name>Java.net Snapshot Repository for Maven</name> 
 
      <url>https://maven.java.net/content/repositories/staging/</url> 
 
      <layout>default</layout> 
 
     </repository> 
 
     <repository> 
 
      <id>releases-repository.java.net</id> 
 
      <name>Java.net releases Repository for Maven</name> 
 
      <url>https://maven.java.net/content/repositories/releases/</url> 
 
      <layout>default</layout> 
 
     </repository> 
 
    </repositories> 
 
    
 
    <build> 
 
     <pluginManagement> 
 
      <plugins> 
 
       <plugin> 
 
        <groupId>org.apache.maven.plugins</groupId> 
 
        <artifactId>maven-compiler-plugin</artifactId> 
 
        <version>${maven.compiler.plugin.version}</version> 
 
       </plugin> 
 
       <plugin> 
 
        <groupId>org.apache.maven.plugins</groupId> 
 
        <artifactId>maven-source-plugin</artifactId> 
 
        <version>${maven.source.plugin.version}</version> 
 
       </plugin> 
 
       <plugin> 
 
        <groupId>org.apache.maven.plugins</groupId> 
 
        <artifactId>maven-clean-plugin</artifactId> 
 
        <version>${maven.clean.plugin.version}</version> 
 
       </plugin> 
 
       <plugin> 
 
        <groupId>org.apache.maven.plugins</groupId> 
 
        <artifactId>maven-war-plugin</artifactId> 
 
        <version>${maven.war.plugin.version}</version> 
 
       </plugin> 
 
       <plugin> 
 
        <groupId>org.codehaus.cargo</groupId> 
 
        <artifactId>cargo-maven2-plugin</artifactId> 
 
        <version>${cargo.plugin.version}</version> 
 
       </plugin> 
 
      </plugins> 
 
     </pluginManagement> 
 
     <plugins> 
 
      <plugin> 
 
       <groupId>org.codehaus.cargo</groupId> 
 
       <artifactId>cargo-maven2-plugin</artifactId> 
 
       <inherited>true</inherited> 
 
       <executions> 
 
        <execution> 
 
         <id>deploy</id> 
 
         <phase>integration-test</phase> 
 
         <goals> 
 
          <goal>redeploy</goal> 
 
         </goals> 
 
        </execution> 
 
       </executions> 
 
       <configuration> 
 
        <container> 
 
         <containerId>${integration.container.id}</containerId> 
 
         <type>installed</type> 
 
         <home>${glassfish.home}</home> 
 
        </container> 
 
        <configuration> 
 
         <type>existing</type> 
 
         <home>${glassfish.home}/glassfish/domains</home> 
 
         <properties> 
 
          <cargo.glassfish.domain.name>${glassfish.domain.name}</cargo.glassfish.domain.name> 
 
          <!--cargo.remote.username></cargo.remote.username--> 
 
          <cargo.remote.password /> 
 
         </properties> 
 
        </configuration> 
 
       </configuration> 
 
      </plugin> 
 
      <plugin> 
 
       <groupId>org.apache.maven.plugins</groupId> 
 
       <artifactId>maven-compiler-plugin</artifactId> 
 
       <version>${maven.compiler.plugin.version}</version> 
 
       <configuration> 
 
        <source>1.8</source> 
 
        <target>1.8</target> 
 
       </configuration> 
 
      </plugin> 
 
      <plugin> 
 
       <groupId>com.mycila.maven-license-plugin</groupId> 
 
       <artifactId>maven-license-plugin</artifactId> 
 
       <version>${maven.license.plugin.version}</version> 
 
       <configuration> 
 
        <header>common/license.txt</header> 
 
        <excludes> 
 
         <exclude>common/**</exclude> 
 
         <exclude>**/META-INF/**</exclude> 
 
         <exclude>**/WEB-INF/**</exclude> 
 
         <exclude>**/nbactions.xml</exclude> 
 
         <exclude>**/nb-configuration.xml</exclude> 
 
         <exclude>**/glassfish-resources.xml</exclude> 
 
         <exclude>**/simple-flow-flow.xml</exclude> 
 
        </excludes> 
 
       </configuration> 
 
      </plugin> 
 
      <plugin> 
 
       <artifactId>maven-release-plugin</artifactId> 
 
       <version>${maven.release.plugin.version}</version> 
 
       <configuration> 
 
        <!-- 
 
        During release:perform, enable the "sdk" profile 
 
        --> 
 
        <releaseProfiles>sdk</releaseProfiles> 
 
        <autoVersionSubmodules>true</autoVersionSubmodules> 
 
       </configuration> 
 
      </plugin> 
 
     </plugins> 
 
    </build> 
 
    
 
    
 
    <dependencies> 
 
     <dependency> 
 
      <groupId>javax</groupId> 
 
      <artifactId>javaee-api</artifactId> 
 
      <version>${javaee.api.version}</version> 
 
      <scope>provided</scope> 
 
     </dependency> 
 
    </dependencies> 
 

 
</project>

我的孩子的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/xsd/maven-4.0.0.xsd"> 
 
    <modelVersion>4.0.0</modelVersion> 
 

 
    <parent> 
 
     <artifactId>servlet</artifactId> 
 
     <groupId>org.glassfish.javaeetutorial</groupId> 
 
     <version>7.0.5</version> 
 
    </parent> 
 
    
 
    <groupId>org.glassfish.javaeetutorial</groupId> 
 
    <artifactId>hello2</artifactId> 
 
    <version>7.0.5</version> 
 
    <packaging>war</packaging> 
 

 
    <name>hello2</name> 
 
</project>

後,我跑MVN安裝我的錯誤:

enter image description here

任何幫助將不勝感激!

+0

您正在編譯Program Files中的一個項目,這看起來很可疑。這些文件夾通常是寫保護的。將您的來源複製到例如您的文檔文件夾,然後重試? –

+0

我現在看到教程說你不能使用Netbeans嵌入的glassfish。 :(聽起來可能是這個問題,將單獨重新安裝glassfish並恢復原狀。 – Arnie

+0

這樣做和它的工作 - 非常感謝你。你可以張貼它作爲答案,我會投票。不知道爲什麼Oracle希望我們從Glassfish更新中心安裝教程示例,而不是單獨地。 – Arnie

回答

1

您正在編譯程序文件中的項目。 這些文件夾通常是寫保護的。

將Glassfish重新安裝到讀/寫不成問題的文檔文件夾中。

Maven並不傾向於擁有世界上最有幫助的錯誤消息 - 這裏的問題不在於無法找到目錄,它似乎更像是一個無法創建的目錄!

相關問題