我有一个这样的 Spring Security 配置:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Override
....
ide 告诉我无法自动装配 dataSource 但我已经在 RootConfiguration 类中配置了 dataSource bean:
@Configuration
@EnableTransactionManagement
@PropertySource("classpath:application.properties")
@EnableJpaRepositories("com.zero.mvc.repository")
@ComponentScan("com.zero.mvc")
@Import(SecurityConfig.class)
public class RootConfiguration {
....
@Bean
public DataSource dataSource()
...
我不明白为什么....谢谢!