Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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
如何设置基于spring的java库?_Spring_Autowired - Fatal编程技术网

如何设置基于spring的java库?

如何设置基于spring的java库?,spring,autowired,Spring,Autowired,我正在尝试创建一个使用spring的java库。但是我找不到任何资源来向您展示如何设置组件扫描并在您没有应用程序的主入口点时加载所有bean。spring使用的一种常见方法是定义一个@EnableXXXX,并让库的客户端通过在其配置类上注释来启用它。比如: @Target(ElementType.TYPE) @导入(配置.class) @记录 public@interface enableBoolibaray{ } @ComponentScan(“xxxxx”) @配置 公共类配置{ } 和

我正在尝试创建一个使用spring的java库。但是我找不到任何资源来向您展示如何设置组件扫描并在您没有应用程序的主入口点时加载所有bean。

spring使用的一种常见方法是定义一个
@EnableXXXX
,并让库的客户端通过在其配置类上注释来启用它。比如:

@Target(ElementType.TYPE)
@导入(配置.class)
@记录
public@interface enableBoolibaray{
}
@ComponentScan(“xxxxx”)
@配置
公共类配置{
}
和客户端通过以下方式启用您的库:

@enableboullibaray
@配置
公共类应用程序{
}
实际上,
@Import
支持一种更动态的方式来包含库的bean设置。您可以参考spring提供的许多现有的
@EnableXXX
,例如
@EnableAsync
@EnableWebSecurity
@EnableTransactionManagement
@EnableCaching
等,了解许多示例