在springboot启动报错:No qualifying bean of type 'javax.sql.DataSource' available: expected at lea

Posted dangerous_11

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在springboot启动报错:No qualifying bean of type 'javax.sql.DataSource' available: expected at lea相关的知识,希望对你有一定的参考价值。

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 lea的主要内容,如果未能解决你的问题,请参考以下文章

springboot项目启动报错 url' attribute is not specified and no embedded datasource could be configured

第一个springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no

springboot启动报错 Failed to configure a DataSource: 'url' attribute is not specified and no emb

Springboot项目启动报错Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded d

Springboot启动后报错This application has no explicit mapping for /error, so you are seeing this as a fal

activity启动报错no processes deployed with key '***'