tags: postgresql Configuration application druid
First, there is no connection pool configuration
server:
port: 4567
spring:
datasource:
username: postgres
password: 123456
url: jdbc:postgresql://localhost:5432/myjpaproject
driver-class-name: org.postgresql.Driver
jpa:
Database-platform: org.hibernate.dialect.PostgreSQL95Dialect #Set dialect
properties:
hibernate:
Jdbc.lob.non_contextual_creation: true # Prevent the postgresql database from checking for data errors caused by not implementing CLOB format
Or multi-environment configuration (only the development environment is added here), test and production environment can be added later
server:
port: 4567
spring:
profiles:
Active: dev #default active profiles
jpa:
Database-platform: org.hibernate.dialect.PostgreSQL95Dialect #Set dialect
properties:
hibernate:
Jdbc.lob.non_contextual_creation: true # Prevent the postgresql database from checking for data errors caused by not implementing CLOB format
---
spring:
profiles: dev
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/myjpaproject
username: postgres
password: 123456
Second, there is a connection pool configuration
Add package to build.gradle
// druid database connection pool
implementation 'com.alibaba:druid-spring-boot-starter:1.1.10'
Configuration:
server:
port: 4567
spring:
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/myjpaproject
username: postgres
password: 123456
Filters: stat #alias mode, extension plugin, filter for monitoring statistics: stat, filter for log: log4j, sql injection filter: wall
or
server:
port: 4567
spring:
profiles:
Active: dev #default active profiles
jpa:
Database-platform: org.hibernate.dialect.PostgreSQL95Dialect #Set dialect
properties:
hibernate:
Jdbc.lob.non_contextual_creation: true # Prevent the postgresql database from checking for data errors caused by not implementing CLOB format
---
spring:
profiles: dev
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/myjpaproject
username: postgres
password: 123456
Filters: stat #alias mode, extension plugin, filter for monitoring statistics: stat, filter for log: log4j, sql injection filter: wall
All driud configuration:
db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/myjpaproject
username: postgres
password: 123456
# The following is a supplementary setting for the connection pool, applied to all the above data sources
# Initialize size, minimum, maximum
initialSize: 1
minIdle: 3
maxActive: 20
# Configure the timeout for waiting for the connection to wait.
maxWait: 60000
# Configure the interval to detect once, and detect the idle connection that needs to be closed. The unit is milliseconds.
timeBetweenEvictionRunsMillis: 60000
# Configure the minimum lifetime of a connection in the pool, in milliseconds
minEvictableIdleTimeMillis: 30000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# Open PSCache and specify the size of PSCache on each connection.
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# Configure monitoring statistics interception filters, remove the monitoring interface sql can not be counted, 'wall' for firewall, #alias mode, extension plug-in, monitor statistics filter: stat, log filter: log4j, defense sql injection filter :wall
filters: stat,slf4j
# Open the mergeSql function via the connectProperties property; slow SQL logging
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
Create a SpringBoot entry instance - STS mode SpringBoot 2.0 integrates Mybatis Connect the above two, based on the integrated mybatis, integrated druid The structure of the project after the transfor...
1. Introducing Pom dependence 2, add druid configuration information ...
1. new pom.xml, druid dependency and log4j dependency 2.application.properties added 3. New configuration class, add @Configuration annotation, spring boot can think it is a configuratio...
The demo is developed using IDEA tools, and the environment is JDK1.7+SpringBoot 1.5.5. It is the same for other versions, with little difference. First use IDEA to create a new SpringBoot project, th...
1. Introduce dependency packages Second, springboot assembly Three, application configuration file configuration Fourth, visit Druid monitoring Visithttp://127.0.0.1:8080/druid/index.html, Enter the c...
1. Add dependency in [pom.xml] 2. Add configuration items in the application.yml file 3. Create Druid configuration class 4. Test Enter the access address in the browser: http://localhost:8080/druid/ ...
This is ali's open source project druid. The druid connection pool is a very commonly used connection pool, the effect is quite good, and it is also the son of ali. add in pom.xml Some configuration T...
1. Core dependencies rely Description HavestarterGuidestarter mysqlAlready integratedspring boot 2. Configuration file application.ymlMain configuration file application-dev.yml application-druid.yml ...
DRUID introduction: DrUID is a database connection pool implementation on Alibaba open source platform. It combines the advantages of C3P0, DBCP, Proxool, etc., and joining log monitoring, you can mon...
Springboot 2.0 integrated DRUID connection pool First import a Druid and log of MAVEN dependence It is also necessary to import the following dependencies, otherwise the following fault will be report...