Reputation: 1756
I have a spring boot application with the following configuration:
Application
@SpringBootApplication(exclude = {ErrorMvcAutoConfiguration.class,
DataSourceAutoConfiguration.class,JpaRepositoriesAutoConfiguration.class})
public class Application extends SpringBootServletInitializer {
Main configuration class:
@Configuration
@ComponentScan("com.mycompany.it")
@Import(DatabaseConfiguration.class)
public class Configuration extends WebMvcConfigurationSupport {
Database configuration:
@Configuration
@ComponentScan(basePackages = {"com.mycompany.it.xp2.integration.workday.dao","com.mycompany.it.xp2.integration.workday.application","com.company.it.xp2.integration.workday.model"})
@EnableAspectJAutoProxy
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"com.company.it.xp2.integration.workday.dao","com.company.it.xp2.integration.workday.model"})
public class DatabaseConfiguration {
With DataSource bean declaration:
@Bean(destroyMethod = "close")
@Primary
public DataSource dataSource() throws PropertyVetoException {
ComboPooledDataSource source = new ComboPooledDataSource();
source.setDriverClass(driverClass);
source.setJdbcUrl(jdbcUrl);
source.setUser(jdbcUsername);
source.setPassword(jdbcPassword);
source.setInitialPoolSize(initialSize);
source.setMaxPoolSize(maxActive);
source.setMinPoolSize(minIdle);
return source;
}
However when I start up the application I get the following error:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Here are the related lines from gradle:
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
compile group: 'org.springframework', name: 'spring-orm'
compile group: "org.springframework.boot", name: "spring-boot-starter-jdbc"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
Spring boot version 1.5.3
Upvotes: 0
Views: 821
Reputation: 366
Check the error log
1 bean which qualifies as autowire candidate. Dependency annotations
It seems that there is an error when you configured the bean.
Upvotes: 0