在部署到GCP时,我的构建成功,但是我遇到了应用程序启动错误。该应用程序在本地主机上运行良好。
我的pom.xml
是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.sample</groupId>
<artifactId>catapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>catapi</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
错误如下:
起因:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“ org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration $ JdbcTemplateConfiguration”的bean时出错:通过构造函数参数0表示的不满意依赖关系;嵌套的异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / jdbc / DataSourceConfiguration $ Hikari.class]中创建名称为“ dataSource”的bean时出错。嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker的bean时出错:调用init方法失败;嵌套的异常是org.springframework.jdbc.datasource.init.UncategorizedScriptException:无法执行数据库脚本;无法执行。嵌套的异常是org.springframework.jdbc.CannotGetJdbcConnectionException:无法获取JDBC连接。嵌套的异常是org.postgresql.util.PSQLException:到本地主机的连接:5432被拒绝。检查主机名和端口是否正确以及邮局主管正在接受TCP / IP连接。 org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java)
请帮助我解决此错误。