Reputation: 26294
I tried to follow this answer to add JDBC TokenStore to my app.
https://stackoverflow.com/a/37595818/148844
It is working with an InMemoryTokenStore
. I need to know where to put this code
@Bean(name = "OAuth")
@ConfigurationProperties(prefix="datasource.oauth")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
I tried to put it in
@Configuration
@EnableAuthorizationServer
public class OAuth2Configuration extends AuthorizationServerConfigurerAdapter {
But I got the error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OAuth2Configuration': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'OAuth': Requested bean is currently in creation: Is there an unresolvable circular reference?
So I moved it to the main class
@SpringBootApplication
@MapperScan("com.example.mapper")
public class ExampleApplication extends SpringBootServletInitializer {
But then it gave a different error
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The url cannot be null
So where do I put that snippet to define the bean?
Upvotes: 0
Views: 750
Reputation: 9806
You need to have the database configuration properties in your application-{profile}.properties
, in particular they need to be prefixed by datasource.oauth
. Here profile
will be any of the profiles that your application is running on (e.g: dev, stage, prod).
The error that is showing clearly says that there is no datasource.oauth.url=..
property in the specific properties file.
Upvotes: 1