繁体   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