2015-10-01 124 views
0

我有POM這樣的:Maven的POM不能編譯文件

<?xml version="1.0" encoding="UTF-8"?> 
<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>com.project</groupId> 
    <artifactId>automation</artifactId> 
    <packaging>pom</packaging> 
    <version>1.0-SNAPSHOT</version> 

    <build> 
     <directory>target</directory> 
     <outputDirectory>target/classes</outputDirectory> 
     <finalName>AUTOMATION-01</finalName> 
     <testOutputDirectory>target/test-classes</testOutputDirectory> 
     <sourceDirectory>src/main/java</sourceDirectory> 
     <testSourceDirectory>src/test/java</testSourceDirectory> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
      </resource> 
     </resources> 
     <testResources> 
      <testResource> 
       <directory>src/test/resources</directory> 
      </testResource> 
     </testResources> 
    </build> 

    <reporting> 
     <outputDirectory>target/site</outputDirectory> 
    </reporting> 

    <profiles> 

     <profile> 
      <id>release-profile</id> 

      <activation> 
       <property> 
        <name>performRelease</name> 
       </property> 
      </activation> 

      <build> 
       <plugins> 

        <plugin> 
         <inherited>true</inherited> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-source-plugin</artifactId> 

         <executions> 
          <execution> 
           <id>attach-sources</id> 
           <goals> 
            <goal>jar</goal> 
           </goals> 
          </execution> 
         </executions> 
        </plugin> 

        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-compiler-plugin</artifactId> 
         <version>3.3</version> 
         <configuration> 
          <source>1.7</source> 
          <target>1.7</target> 
         </configuration> 
        </plugin> 

        <plugin> 
         <inherited>true</inherited> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-deploy-plugin</artifactId> 
         <configuration> 
          <updateReleaseInfo>true</updateReleaseInfo> 
         </configuration> 
        </plugin> 

       </plugins> 

      </build> 
     </profile> 
    </profiles> 


    <dependencies> 
     <dependency> 
      <groupId>javax.xml.ws</groupId> 
      <artifactId>jaxws-api</artifactId> 
      <version>2.2.11</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-io</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>2.4</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-lang</groupId> 
      <artifactId>commons-lang</artifactId> 
      <version>2.6</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.17</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2.11</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.jaxb</groupId> 
      <artifactId>jaxb-runtime</artifactId> 
      <version>2.2.11</version> 
     </dependency> 

    </dependencies> 

</project> 

我不明白爲什麼我無法從我的源目錄輸出目錄編譯文件。

至於結果我有

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building automation 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.104s 
[INFO] Finished at: Thu Oct 01 15:05:28 MSK 2015 
[INFO] Final Memory: 6M/72M 
[INFO] ------------------------------------------------------------------------ 

Process finished with exit code 0 

但是,在所有放置找不到<我想是不是產生 它將被放置,我想有我遵守文件旁邊,並在同一文件夾與我的源文件全部打包在文件夾目標爲例 我在哪裏錯了?

+1

你的問題是_really_不清楚。你能提供更多細節嗎?你想在哪裏編譯類被定位?順便說一句,你爲什麼重新定義'sourceDirectory'等?只刪除這些,它是默認值。 – Tunaki

+0

我在我的pom.xml中有什麼不起作用,因爲我期待有一些輸出文件夾與生成的文件一起出現。 –

+0

你有什麼類可以在'src/main/java'下編譯嗎? – Tunaki

回答

2

您的POM指定<packaging>pom。將其更改爲jar

+0

謝謝你爲我工作。 pom如何影響這個? –

+0

https://maven.apache.org/pom.html#Maven_Coordinates-> packaging – YoungHobbit

+1

' pom'主要用於多模塊構建或指定另一個POM可以導入的可重用依賴項集。包裝基本上規定了Maven項目的主要輸出(jar,war,ear等)應該是什麼。 – Daniel