2017-04-06 62 views

回答

1

您可以使用組件掃描。

@Configuration 
@ComponentScan(basePackages = "org.example.configs") 
public class Config { 
} 

org.example.configs包中的所有@Configuration類將包含在上下文中。

類型安全替代:

// org.example.configs.SubConfig 
@ComponentScan(basePackageClasses = SubConfig.class) 
2

<import resource="folder/*.xml" />掛件但使用配置是@ImportResource

例如:

@Configuration 
@ImportResource("folder/*.xml") 
public class MyConfiguration {}