Maven编译不创建.class

时间:2018-02-14 15:20:42

标签: java maven

我正在使用以下命令从命令行(即不通过IDE)构建我的Maven项目:

mvn package

但是,资源被复制到target/classes,但文件夹是空的(即没有构建类文件)。

我的package命令的输出如下:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building graph-utils-server 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ graph-utils-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ graph-utils-server ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 12 source files to /home/bakerj/graphutilsserver/src/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ graph-utils-server ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/bakerj/graphutilsserver/src/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ graph-utils-server ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ graph-utils-server ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ graph-utils-server ---
[INFO] Building jar: /home/bakerj/graphutilsserver/src/target/graph-utils-server-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.013 s
[INFO] Finished at: 2018-02-14T15:14:12+00:00
[INFO] Final Memory: 34M/943M
[INFO] ------------------------------------------------------------------------

注意,我的项目的根目录是/home/bakerj/graphutilserver/src(即POM所在的位置以及我从哪里运行Maven)。保存实际代码的下面有一个src文件夹。

我可以看到它正在拾取我拥有的12个源文件,但它们没有被编译(或者至少没有按预期放入target/classes文件夹。

$ mvn -v

Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "4.10.0-42-generic", arch: "amd64", family: "unix"

关于出了什么问题的任何建议?

更新 - 下面包含的POM文件(如果导致问题,我已注释掉spring-boot-maven-plugin,但如果取消注释则结果相同)。

<?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>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
    </parent>

    <groupId>myproject</groupId>
    <artifactId>graph-utils-server</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>myproject</groupId>
            <artifactId>graph-utils</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>myproject</groupId>
            <artifactId>data-to-graph-mapper</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

        <!-- AWS -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>1.11.276</version>
        </dependency>

        <!-- Gremlin -->
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>tinkergraph-gremlin</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>2.4.11</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-console</artifactId>
            <version>2.4.11</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-xml</artifactId>
            <version>2.4.11</version>
        </dependency>

        <!-- JanusGraph -->
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-core</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-hbase</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.janusgraph</groupId>
            <artifactId>janusgraph-lucene</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.4.1</version>
        </dependency>
    </dependencies>

    <!-- <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build> -->
</project>

更新 - 因为它引起了一些混淆,这是我的文件夹结构:

$ pwd
/home/bakerj/graphutilsserver/src

$ tree
.
├── pom.xml
└── src
    └── main
        ├── java
        │   └── myproject
        │       └── graphutils
        │           └── server
        │               ├── controllers
        │               │   ├── ClearGraph.java
        │               │   ├── CreateGraph.java
        │               │   ├── LoadGraph.java
        │               │   ├── MergeGraph.java
        │               │   └── TransformGraph.java
        │               ├── exceptions
        │               │   ├── BadRequestException.java
        │               │   ├── NotFoundException.java
        │               │   └── ServerErrorException.java
        │               ├── GraphUtilsServer.java
        │               └── utils
        │                   ├── ConfigUtils.java
        │                   ├── FileUtils.java
        │                   └── S3Utils.java
        └── resources
            └── janusgraph-hbase.properties

13 directories, 14 files

更新 - 我刚刚在另一台机器上构建了相同的代码(通过Git签出,因此应该是相同的)并且工作正常。所以它似乎与我的配置而不是代码本身有关。两台计算机都运行相同版本的Java和Maven。关于在哪里寻找差异的任何想法?

0 个答案:

没有答案