‘javax.sql.DataSource‘ that could not be found的问题

报错信息如下:
2024-02-04 16:31:14.832  WARN 952 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'databaseConfig': Unsatisfied dependency expressed through field 'dataSource'; 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: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2024-02-04 16:31:14.835  INFO 952 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2024-02-04 16:31:14.849  INFO 952 --- [           main] ConditionEvaluationReportLoggingListener : 

‘javax.sql.DataSource‘ that could not be found的问题_第1张图片

原因是SpringbootApplication上面的注解需要把 exclude 去掉,去掉后完美解决

@SpringBootApplication
public class SpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }

你可能感兴趣的:(java)