场景:
search服务junit测试跑不起来,代码啥也没改过
排查:
...
Failed to instantiate [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]
...
dataSource or dataSourceClassName or jdbcUrl is required
org.springframework.boot.jdbc.DataSourceBuilder#build
private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
"com.zaxxer.hikari.HikariDataSource",
"org.apache.tomcat.jdbc.pool.DataSource",
"org.apache.commons.dbcp2.BasicDataSource" };
private Map<String, String> properties = new HashMap<>();
private void maybeGetDriverClassName() {
if (!this.properties.containsKey("driverClassName")
&& this.properties.containsKey("url")) {
String url = this.properties.get("url");
String driverClass = DatabaseDriver.fromJdbcUrl(url).getDriverClassName();
this.properties.put("driverClassName", driverClass);
}
}
发现其properties hashMap 没有内容
即配置在application.properties中的内容未生效
原因及解决:
在IDEA中查看module,发现有两个module
一个是xxxx-elasticsearch-service,另一个是com.xxxx.xxxx.esearch.xxxx-elasticsearch-service
原来gradle中配置了
group = 'com.xxxx.xxxx.esearch'
version = '0.0.1-SNAPSHOT'
将group注释掉,重新导入project,就可以正常测试了
怀疑这些都是IDEA自身的问题,当打包之后,其classes中文件夹的格式仍旧是com/xxxx/xxxx/esearch
版权声明:本文为u013905744原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。