Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.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 如何使用Archunit仅测试具有特定Spring配置文件的类_Java_Spring_Archunit - Fatal编程技术网

Java 如何使用Archunit仅测试具有特定Spring配置文件的类

Java 如何使用Archunit仅测试具有特定Spring配置文件的类,java,spring,archunit,Java,Spring,Archunit,我有一个Spring应用程序,它有不同的配置文件,例如“dev”和“production”。我用Archunit测试架构。我有这样的测试 @Test public void Services_should_only_be_accessed_by_Controllers() { JavaClasses importedClasses = new ClassFileImporter().importPackages("com.mycompany.myapp");

我有一个Spring应用程序,它有不同的配置文件,例如“dev”和“production”。我用Archunit测试架构。我有这样的测试

@Test
public void Services_should_only_be_accessed_by_Controllers() {
    JavaClasses importedClasses = new ClassFileImporter().importPackages("com.mycompany.myapp");

    ArchRule myRule = classes()
        .that().resideInAPackage("..service..")
        .should().onlyBeAccessed().byAnyPackage("..controller..", "..service..");

    myRule.check(importedClasses);
}
我的包中的类具有不同的配置文件。我怎样才能只包含具有Spring概要文件“production”的类?

JavaClasses importedClasses=new ClassFileImporter().importPackages(“com.mycompany.myapp”)
.that(descripebedpredicate.descripe(“profile”),clazz->
课堂讲义(Profile.class)和
Arrays.asList(clazz.getAnnotationOfType(Profile.class).value()).contains(“production”);