Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 多模块Maven项目-在jar中包含测试bean_Java_Spring_Maven - Fatal编程技术网

Java 多模块Maven项目-在jar中包含测试bean

Java 多模块Maven项目-在jar中包含测试bean,java,spring,maven,Java,Spring,Maven,如何在导入到另一个模块的jar中包含testdir(src/test/)下的springbean 我有几个Maven项目:ms1、ms2、ms3和general shared。通用共享是一个多模块Maven项目。它包含几个模块:通用共享UTILL、通用共享fs等 在每个子模块中,我都有一个专用的pom.xml,其中包含所需的所有依赖项,在通用共享pom中,我有关于构建和模块的详细信息: <build> <plugins> <

如何在导入到另一个模块的jar中包含testdir(src/test/)下的springbean

我有几个Maven项目:ms1、ms2、ms3和general shared。通用共享是一个多模块Maven项目。它包含几个模块:通用共享UTILL、通用共享fs等

在每个子模块中,我都有一个专用的pom.xml,其中包含所需的所有依赖项,在通用共享pom中,我有关于构建和模块的详细信息:

  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <modules>
        <module>general-shared-utills</module>
        <module>general-shared-fs</module>
    </modules>
在/src/test下:

@Component
@Profile("test")
public class AWSServiceMock extends AWSService 
在ms1的pom中导入general shared utills模块时,我希望它包括AWSServiceMock类。目前,ms1的测试找不到任何AWSService类型的bean,因为它没有一个具有测试概要文件的AWSService类型的bean:

 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'a.x.y.aws.AWSService ' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
我将相关bean(mock)从src/test目录移动到src/main

我也在maven的网站上找到了

如果有人会有另一个实际的答案,我会很高兴听到并更新帖子的答案

 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'a.x.y.aws.AWSService ' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}