I am working on a Spring Boot Batch example with MongoDB and I have already started the mongod
server.
When I launch my application, I
If you're using Gradle, rebuild Gradle can solve this problem.
It's happening because the @valerio-vaudi said.
Your problem is the dependency of spring batch spring-boot-starter-batch that has a spring-boot-starter-jdbc transitive maven dependency.
But you can resolve it set the primary datasource with your configuration
@Primary
@Bean(name = "dataSource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource getDataSource() {
return DataSourceBuilder.create().build();
}
@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
In my case
spring.profiles = production // remove it to fix
in application.properties was the reason
I think when importing modules you have imported another package, Go to modules and remove al of them. After that import modules from the package of the project
I removed an obsolete dependency on mybatis in the pom.xml to get mine running.
Add this annotation in main java file
@EnableAutoConfiguration(exclude=DataSourceAutoConfiguration.class)