0

In build.gradle I have:

compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-web-services'
compile 'org.springframework.boot:spring-boot-starter-amqp'
compile("org.springframework.boot:spring-boot-starter-jdbc") {
    exclude module: "spring-boot-starter-hikari"
}
compile group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '9.0.21'

I try to configure DataSource in application.yml (located in tomcat/../resource_directory)

spring:
datasource:
    jdbc-url: "jdbc:oracle:thin: ...."
    username: "admin"
    password: "admin"
    driver-class-name: "oracle.jdbc.driver.OracleDriver"
    type: "org.apache.tomcat.jdbc.pool.DataSource" 
    tomcat:
        initialSize: 55
        max-wait: 10000
        max-active: 50
        max-idle: 15
        min-idle: 8
        default-autoCommit: false

And I use @Autowired in my code. But when I debug my code I hava next:

log.info("dataSource: " + dataSource.toString());1
log.info("dataSourceClass: " + dataSource.getClass());2
dataSource: HikariDataSource (null) 1
dataSourceClass: class com.zaxxer.hikari.HikariDataSource 2

In log file I saw next:

Loaded 1 document from YAML resource // with correct path to file.

And correct loaded data:

spring={datasource={jdbc-url=jdbc...., username=admin, password=admin, driver-class-name=oracle.jdbc.driver.OracleDriver, 
type=org.apache.tomcat.jdbc.pool.DataSource, tomcat={initialSize=55, max- 
wait=10000, max-active=50, max-idle=15, min-idle=8, default- 
autoCommit=false}}}

When I put config to application.propertes in src/resources I get correct tomcat dataSource.

dataSource: org.apache.tomcat.jdbc.pool.DataSourc //1
dataSourceClass: class org.apache.tomcat.jdbc.pool.DataSource//2

What I do wrong!?? Help me please with this confuse.

Alex
  • 103
  • 1
  • 10
  • Why don't you place yml in resources like properties file.In case of both properties will be picked so keep only yml one. – Niraj Jha Nov 06 '19 at 20:57

1 Answers1

0

You should actually exclude:

com.zaxxer:HikariCP

Edit: Also, I think this answer may help too

Julio_Av
  • 23
  • 6