码迷,mamicode.com
首页 > 数据库 > 详细

在springboot启动报错:No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

时间:2019-09-20 10:33:01      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:tap   driver   settings   highlight   pat   vax   type   ring   ble   

1.

@SpringBootApplication
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

  这种情况 会报错 

No qualifying bean of type ‘javax.sql.DataSource‘ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

2.

@SpringBootApplication
@EnableAutoConfiguration
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

  这种情况会报错:Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

 

 

正确的应该是:

@SpringBootApplication
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

  

在springboot启动报错:No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

标签:tap   driver   settings   highlight   pat   vax   type   ring   ble   

原文地址:https://www.cnblogs.com/dangerous-11/p/11555200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!