Maven无法编译测试类

时间:2014-12-18 11:02:37

标签: maven maven-3 maven-plugin

我想从不同目录编译源代码。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <includes>
                    <include>src/main/java/**/*.java</include>
                    <include>generated-sources</include>
                </includes>
                <source>1.6</source>
            </configuration>
        </plugin>

每当我尝试构建时,我都会在测试类上遇到错误:

[INFO] [compiler:testCompile {execution: default-testCompile}]

[ERROR] /home/user/project/src/test/java/com/company/model/hub/ToplogyFileUtilsTest.java:[8,45] error: package com.company.model.logic.hub does not exist

[ERROR] /home/user/project/src/test/java/com/company/model/entity/cfg/dto/OidDTOTest.java:[11,43] error: package com.company.model.dto.cfg does not exist

[ERROR] /home/user/project/src/test/java/com/company/model/fault/EventTest.java:[12,48] error: package com.company.model.entity.fault does not exist
...

1 个答案:

答案 0 :(得分:0)

您错过了添加测试类的来源。将其添加到包含

<include>src/test/java/**/*.java</include>