From 93eca239cb3d25f12924555d0b13d7cef7a2c030 Mon Sep 17 00:00:00 2001 From: Yang Jing Date: Thu, 2 Jul 2020 21:39:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=20spring.profiles.active=20?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E9=85=8D=E7=BD=AE=E6=9D=A5=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=B8=8D=E5=90=8C=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- web/src/main/resources/application-mysql.yml | 32 +++++++++++++++++ web/src/main/resources/application-pg.yml | 36 +++++++++++++++++++ web/src/main/resources/application.yml | 38 +------------------- 4 files changed, 70 insertions(+), 38 deletions(-) create mode 100644 web/src/main/resources/application-mysql.yml create mode 100644 web/src/main/resources/application-pg.yml diff --git a/README.md b/README.md index 518965a5..48e45106 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ create user admin encrypted password 'admin'; create database kafka_manager owner=admin template=template0 encoding='UTF-8' lc_collate='zh_CN.UTF-8' lc_ctype='zh_CN.UTF-8'; ``` -***根据所选择的数据库,请修改 [application.yml](web/src/main/resources/application.yml) 相应配置。*** +***根据所选择的数据库,使用 `-Dspring.profiles.active=pg` 指定配置文件,默认使用 `mysql`。*** --- diff --git a/web/src/main/resources/application-mysql.yml b/web/src/main/resources/application-mysql.yml new file mode 100644 index 00000000..81c49e28 --- /dev/null +++ b/web/src/main/resources/application-mysql.yml @@ -0,0 +1,32 @@ +server: + port: 8080 + tomcat: + accept-count: 100 + max-connections: 1000 + max-threads: 20 + min-spare-threads: 20 + +spring: + application: + name: kafkamanager + datasource: + kafka-manager: + driver-class-name: org.mariadb.jdbc.Driver + jdbc-url: jdbc:mysql://localhost:3306/kafka_manager?characterEncoding=UTF-8&serverTimezone=GMT%2B8 + username: admin + password: admin + main: + allow-bean-definition-overriding: true + + profiles: + active: dev + +logging: + config: classpath:logback-spring.xml + +# kafka监控 +kafka-monitor: + enabled: true + notify-kafka: + cluster-id: 95 + topic-name: kmo_monitor diff --git a/web/src/main/resources/application-pg.yml b/web/src/main/resources/application-pg.yml new file mode 100644 index 00000000..e3530369 --- /dev/null +++ b/web/src/main/resources/application-pg.yml @@ -0,0 +1,36 @@ +server: + port: 8080 + tomcat: + accept-count: 100 + max-connections: 1000 + max-threads: 20 + min-spare-threads: 20 + +spring: + application: + name: kafkamanager + datasource: + kafka-manager: + driver-class-name: org.postgresql.Driver + jdbc-url: jdbc:postgresql://localhost:5432/kafka_manager?reWriteBatchedInserts=true + username: admin + password: admin + type: com.zaxxer.hikari.HikariDataSource + hikari: + connection-init-sql: "SET TIME ZONE 'Asia/Chongqing';SET CLIENT_ENCODING TO 'UTF-8';" + connection-test-query: "select 1;" + main: + allow-bean-definition-overriding: true + + profiles: + active: dev + +logging: + config: classpath:logback-spring.xml + +# kafka监控 +kafka-monitor: + enabled: true + notify-kafka: + cluster-id: 95 + topic-name: kmo_monitor diff --git a/web/src/main/resources/application.yml b/web/src/main/resources/application.yml index 5b1a5cff..dc1be31b 100644 --- a/web/src/main/resources/application.yml +++ b/web/src/main/resources/application.yml @@ -1,39 +1,3 @@ -server: - port: 8080 - tomcat: - accept-count: 100 - max-connections: 1000 - max-threads: 20 - min-spare-threads: 20 - spring: - application: - name: kafkamanager - datasource: - kafka-manager: - #driver-class-name: org.postgresql.Driver - #jdbc-url: jdbc:postgresql://localhost:5432/kafka_manager?reWriteBatchedInserts=true - driver-class-name: org.mariadb.jdbc.Driver - jdbc-url: jdbc:mysql://localhost:3306/kafka_manager?characterEncoding=UTF-8&serverTimezone=GMT%2B8 - username: admin - password: admin - type: com.zaxxer.hikari.HikariDataSource - hikari: - # PostgreSQL 使用 - #connection-init-sql: "SET TIME ZONE 'Asia/Chongqing';SET CLIENT_ENCODING TO 'UTF-8';" - connection-test-query: "select 1;" - main: - allow-bean-definition-overriding: true - profiles: - active: dev - -logging: - config: classpath:logback-spring.xml - -# kafka监控 -kafka-monitor: - enabled: true - notify-kafka: - cluster-id: 95 - topic-name: kmo_monitor + active: mysql \ No newline at end of file