Mixed configuration - too late bean creation
Hi,
I have to type of configuration:
1) base on annotations:
Code:
@Bean(destroyMethod="close")
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/test");
dataSource.setUsername("mysql");
dataSource.setPassword("");
return dataSource;
}
2) xml (Spring Security):
Code:
<authentication-manager>
<authentication-provider>
<password-encoder hash="md5">
<salt-source user-property="username" /><!-- ref="saltSource" -->
</password-encoder>
<jdbc-user-service data-source-ref="dataSource" />
</authentication-provider>
</authentication-manager>
Bean created in annotations configuration: dataSource is not visible for Spring Security.
What is wrong with my code?
It is look like dataSource bean is created too late.
(Every thing is ok while I am using it with JPA - before adding security)
Thanks,
Pawel
Edit:
Ok,
I've messed up with configuration.
Code:
<context:component-scan base-package="" />
was placed in file with configuration for org.springframework.web.servlet.DispatcherServlet.
I've moved it to correct place and everything is ok!