Intellij不更新spring.datasource.url

时间:2019-06-28 19:10:07

标签: java spring spring-boot intellij-idea spring-data-jpa

我将项目从sts迁移到intellij,但是intllij无法使用application.properties-> spring.datasource.url更新连接数据库,

控制台日志:

2019-06-28 15:52:27.593 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : MatdmJPAHikariCP - configuration:
2019-06-28 15:52:27.596 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : allowPoolSuspension.............false
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : autoCommit......................true
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : catalog.........................null
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : connectionInitSql...............null
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : connectionTestQuery.............null
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : connectionTimeout...............30000
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : dataSource......................null
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : dataSourceClassName.............null
2019-06-28 15:52:27.597 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : dataSourceJNDI..................null
2019-06-28 15:52:27.599 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : dataSourceProperties............{password=<masked>}
2019-06-28 15:52:27.599 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : driverClassName................."org.postgresql.Driver"
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : healthCheckProperties...........{}
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : healthCheckRegistry.............null
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : idleTimeout.....................30000
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : initializationFailFast..........true
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : isolateInternalQueries..........false
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : jdbc4ConnectionTest.............false
2019-06-28 15:52:27.600 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : jdbcUrl........................."jdbc:postgresql://localhost:5432/meuatendimento"
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : leakDetectionThreshold..........0
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : maxLifetime.....................2000000
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : maximumPoolSize.................20
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : metricRegistry..................null
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : metricsTrackerFactory...........null
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : minimumIdle.....................5
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : password........................<masked>
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : poolName........................"MatdmJPAHikariCP"
2019-06-28 15:52:27.601 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : readOnly........................false
2019-06-28 15:52:27.602 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : registerMbeans..................false
2019-06-28 15:52:27.602 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : scheduledExecutorService........null
2019-06-28 15:52:27.602 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : threadFactory...................null
2019-06-28 15:52:27.602 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : transactionIsolation............null
2019-06-28 15:52:27.602 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : username........................null
2019-06-28 15:52:27.602 DEBUG 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : validationTimeout...............5000
2019-06-28 15:52:27.602  INFO 78161 --- [ost-startStop-1] com.zaxxer.hikari.HikariDataSource       : MatdmJPAHikariCP - Started.
2019-06-28 15:52:27.733  INFO 78161 --- [ost-startStop-1] com.zaxxer.hikari.pool.PoolBase          : MatdmJPAHikariCP - Driver does not support get/set network timeout for connections. (Método org.postgresql.jdbc.PgConnection.getNetworkTimeout() ainda não foi implementado.)
2019-06-28 15:52:27.997  INFO 78161 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'

但是在我的代码中是这样的:

spring.datasource.url=jdbc:postgresql://localhost:5432/newdb
spring.datasource.username=username
spring.datasource.password=pass
spring.datasource.tomcat.max-active=40
spring.datasource.tomcat.max-idle=40
spring.datasource.tomcat.min-idle=40
jpa.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.driver-class-name=org.postgresql.Driver
org.springframework.boot = spring-boot-starter-jersey

# Hikari will use the above plus the following to setup connection pooling
spring.datasource.hikari.minimumIdle=5
spring.datasource.hikari.maximumPoolSize=20
spring.datasource.hikari.idleTimeout=30000
spring.datasource.hikari.poolName=MatdmJPAHikariCP
spring.datasource.hikari.maxLifetime=2000000
spring.datasource.hikari.connectionTimeout=30000

我清除了Intellij的缓存,但无法正常工作。

1 个答案:

答案 0 :(得分:0)

对于Hikari连接池,url属性是jdbc-url,而不是url。所以改变

spring.datasource.url = jdbc:postgresql:// localhost:5432 / newdb

spring.datasource.jdbc-url = jdbc:postgresql:// localhost:5432 / newdb

有关更多信息和其他可能的解决方案,请参见:After Spring Boot 2.0 migration: jdbcUrl is required with driverClassName