我正在开发一个包含 3 个类的简单 Spring 应用程序:
为了理解,我尝试展示 Beans Dependencies 的图表
对于特定的 Bean **ProductService **
这里是三个类的代码
产品服务
@Service
@AllArgsConstructor
public class ProductService {
private final ProductRepo productRepo;
}
产品回购
@AllArgsConstructor
@Repository
public class ProductRepo {
private final JdbcTemplate jdbcTemplate;
}
产品配置
@Configuration
@ComponentScan("com")
public class ProductConfig{
@Bean
public DataSource dataSource()
{
return new DriverManagerDataSource(
"jdbc:mysql://localhost:3306/productnew",
"root",
"root");
}
@Bean
public JdbcTemplate jdbcTemplate(){
return new JdbcTemplate(dataSource());
}
}
然而,productService 注入了 ProductRepo 的依赖项,我没有找到此通信(对于 productService bean,我只是找到 productService 和 productConfig 之间的关联),如图所示。
我尝试刷新IntellijIDEA并删除所有项目的缓存和索引,但问题仍然存在