springBoot打包问题

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

网上各种回答都不符合我的情况,有的说在springboot的启动文件里加一个排除,有说mapper的问题,结果我的问题是在idea里运行完全可以通过,但是线上打包mvn package的话就会报如上的错误。

最后发现是在pom文件里包含的时候,没有写

src/main/resources
而只写了

src/main/java
所以一定要写完整了,不要看到网上跟你写的差不多,但其实还差了一截呢。

resources里面一个是java文件,还有一些资源文件:

<build>
   <plugins>
      <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
   </plugins>
   <resources>
      <resource>
         <directory>src/main/java</directory>
         <includes>
            <include>**/*.xml
            **/*.properties</include>
            <include>**/*.yml
         
         false
      
      
         src/main/resources
         
            **/*.yml</include>
            <include>**/*.properties
            **/*.xml</include>
         </includes>
         <filtering>false</filtering>
      </resource>
   </resources>
</build>

你可能感兴趣的:(spring,boot,java,spring)