簡體   English   中英

使用Postgresql進行Spring Boot的Tomcat配置

[英]Tomcat configuration for Spring Boot with Postgresql

我有一個正在運行的Spring Boot應用程序: https : //github.com/kswr/wallets-api (開發分支),它連接到本地Postgres實例並可以執行get操作。 但是,當我在Tomcat實例上放置.war時,出現以下錯誤

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.                       
HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error  creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method       'dataSource' threw exception; 
nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

我不確定這是Spring Boot還是Tomcat問題,我嘗試為Tomcat安裝postgres驅動程序,並在$CATALINA_HOME/conf/Catalina/localhost/wallets-api-develop.xml如下配置,但似乎沒有改變任何東西

<Context>
<Resource name="jdbc/postgres" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/postgres">
    <parameter>
        <name>validationQuery</name>
        <value>select version();</value>
    </parameter>
    <parameter>
        <name>url</name>
        <value>jdbc:postgresql://localhost:5432/wallets</value>
    </parameter>
    <parameter>
        <name>password</name>
        <value>admin</value>
    </parameter>
    <parameter>
        <name>maxActive</name>
        <value>4</value>
    </parameter>
    <parameter>
        <name>maxWait</name>
        <value>5000</value>
    </parameter>
    <parameter>
        <name>driverClassName</name>
        <value>org.postgresql.Driver</value>
    </parameter>
    <parameter>
        <name>username</name>
        <value>kswr</value>
    </parameter>
    <parameter>
        <name>maxIdle</name>
        <value>2</value>
    </parameter>
</ResourceParams> 
</Context>

實際上這是application.properties的問題; 顯然-D參數在運行時有效,而我的Jenkins管道僅在編譯時提供它們,因此Tomcat無法使用application-staging.properties(包含正確的數據源配置)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM