Mic*_*ash 10 java spring spring-mvc spring-boot
我用Spring组件创建了一个包含在多个项目中的jar(core.jar).
我创建了一个新的Spring项目,将@ComponentScan放到正确的包中,但是它不知道jar中的组件.
如何在包含的JAR中创建Spring的@ComponentScan搜索组件?
Sot*_*lis 18
为其提供适当的包名称以在JAR中扫描.
@ComponentScan(basePackages = {"com.example.from.jar"})
Run Code Online (Sandbox Code Playgroud)
小智 6
我在 Spring boot 和 @ComponentScan 上遇到了类似的问题,这个文档帮助我解决了这个问题:http : //docs.spring.io/spring-boot/docs/current/reference/html/using-boot-structuring-your-代码.html。
关键是我的@SpringBootApplication课程位于 .basePackages 之一的根包中@ComponentScan。在我把它移到一个子包之后,Spring 能够识别所有的@ComponentScans。
| 归档时间: |
|
| 查看次数: |
21375 次 |
| 最近记录: |