今天遇到了一个bug,找了好久时间,最后看代码找到了问题
项目已启动就疯狂报 java.sql.SQLException: unkow jdbc driver : ${jdbc.url} 在网上找了很久,10个帖子有10个不同的原因但是都不能解决我的问题
1.看到这个问题,我首先就是想我的properties文件是不是配置有问题 经过排查 排除了properties文件的问题
2.就是想着是配置spring的配置文件没有配置好(导致没有读取到properties文件) 幸运的是这个项目的配置文件写的还是很规范的 其中有
还有spring-mvc.xml文件在WEB-INF下面
spring-mybatis.xml中
<context:property-placeholder ignore-unresolvable="true" location="classpath*:/config.properties" />
这个配置就是读取properties文件的 那为什么读取不到${jdbc.url}呢?
应为用的德鲁伊的数据源没有写driver 我想会不会是这里出现了什么问题 但是在我加上
后还是回报异常,这就让我确定是项目读取不到我的properties文件 找了好久原因结果发现pom.xml文件中配了
<build>
<finalName>bms_ads</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>
**/classes/*.properties,
**/classes/spring-quartz.xml,
**/classes/logback.xml
</packagingExcludes>
</configuration>
</plugin>
</plugins>
</build>
我当时就差点爆炸去世了,因为这个项目线上要引用外部文件项目就把项目里的配置文件排除了,真实难受,浪费了快一天的时间卡在这里!