我在 Spring Boot (1.5.1.RELEASE) 中有一个使用 Postgres DB (9.1-901-1) 的项目。
当我在生产中运行这个应用程序时,它会在数据库中创建多达 100 个空闲连接。
所以我覆盖了默认配置来控制创建“N”个空闲连接。请检查以下配置:
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/db_name
username: root
password: root
tomcat:
# default value is 100 but postgres' default is 100 as well. To prevent "PSQLException: FATAL: sorry, too many
# clients already", we decrease the max-active value here. Which should be sufficient, by the way
max-active: 10
max-idle: 10
min-idle: 5
max-wait: 30000
time-between-eviction-runs-millis: 5000
min-evictable-idle-time-millis: 60000
jmx-enabled: true
Run Code Online (Sandbox Code Playgroud)
现在它创建了 5 个与 DB 的空闲连接。
我正在通过执行以下查询来验证这一点。
select * …
Run Code Online (Sandbox Code Playgroud) gradle build
在我现有的Spring Boot 项目中执行命令时,该项目/正在使用旧版本的 Gradle(例如:3.4.*)构建良好。
但是在我使用 SDK将 Gradle 升级到最新版本(4.7)后,它在构建时开始抛出错误。
配置清单:
------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------
Build time: 2018-04-18 09:09:12 UTC
Revision: b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_121 (Oracle Corporation 25.121-b13)
OS: Linux 3.16.0-4-amd64 amd64
Run Code Online (Sandbox Code Playgroud)
Spring Boot 详细信息:
springBootVersion = '1.5.1.RELEASE'
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
Run Code Online (Sandbox Code Playgroud)
build.gradle 注意:我无法发布整个构建文件。所以给出一些导入行来分析。
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle- plugin:${springBootVersion}"
}
}
subprojects …
Run Code Online (Sandbox Code Playgroud) 我试图按如下方式映射休眠状态下的postgresql ltree列:
在实体中:
private String path;
@Column(name="org_path", columnDefinition="ltree")
public String getPath() {
return path;
Run Code Online (Sandbox Code Playgroud)
表结构:
CREATE TABLE relationship (
relationship_id int4 NOT NULL,
parent_organization_id uuid NOT NULL,
child_organization_id uuid NOT NULL,
org_path ltree NOT NULL,
CONSTRAINT relationship_pk PRIMARY KEY (relationship_id),
CONSTRAINT organization_fk3 FOREIGN KEY (parent_organization_id) REFERENCES organization(organization_id) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT organization_fk4 FOREIGN KEY (child_organization_id) REFERENCES organization(organization_id) ON DELETE RESTRICT ON UPDATE RESTRICT
)
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
wrong column type encountered in column [org_path] in table [relationship]; found [“schemaName"."ltree" …
Run Code Online (Sandbox Code Playgroud) postgresql ×2
spring-boot ×2
build.gradle ×1
database ×1
entity ×1
gradle ×1
groovy ×1
hibernate ×1
java ×1
ltree ×1
pgbouncer ×1