有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    由于测试文件夹的内容未包含在项目的目标中,所以无法在外部使用。 我认为最好的方法是将公共类移动到像“project testcommons”这样的项目中,并在具有“test”范围的project-a和project-b中使用它

  2. # 2 楼答案

    您可以使用目标测试jar构建项目

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>               
            </plugin>       
    

    然后在项目B中使用类型test-jar将其包括在内:

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>project-a</artifactId>
            <type>test-jar</type>
            <version>1.0-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>