关于spring maven项目properties配置文件不能被编译导致的错误
一开始的错误如下:
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
试了网上的各种方法:加上@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})这个注解,虽然可以解决,但是到后面会报错,后来我发现是我的配置文件properties配置文件没有被编译,故而没有url这些数据,需要把
其中的
<packaging>pom</packaging>
去掉,但是我去掉会报错,又改为其他的jar,war等也会报错,如下:
mybatis的版本修改一下,版本冲突导致的。
这个问题不是properties的问题,而是你引入的包有问题,这个包需要初始化JDBC才行,加上@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})确实可以的,打包方式就是jar,把properties贴出来看看