[英]Importing spring boot jar into another app without @ComponentScan and Xml Configurations
I'm looking for a generic/clean solution to import a spring boot jar application into another spring boot application without doing @ComponentScan(package name of the application), without the xml configuration.我正在寻找一种通用/干净的解决方案,将 spring boot jar 应用程序导入另一个 spring boot 应用程序,而无需执行 @ComponentScan(应用程序的包名称),无需 xml 配置。
If I didn't say @Componentscan in the base application, @Autowired is not working, which is quite understandable.如果我没有在基础应用程序中说@Componentscan,@Autowired 不起作用,这是可以理解的。
So in general writing libraries with spring boot is not a ideal way?所以一般来说用 spring boot 编写库不是一个理想的方式吗?
Finally, I went with @Import(ApplicationConfiguration)which I find it quite neat.最后,我选择了 @Import(ApplicationConfiguration),我觉得它很简洁。
I had a multi-level project structure so on each of the sub-module created a configuration file which initiate the required beans and then in the parent module, I have used @Import.我有一个多级项目结构,所以每个子模块都创建了一个配置文件来启动所需的 bean,然后在父模块中,我使用了 @Import。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.